Example usage for com.liferay.portal.kernel.util ListUtil isEmpty

List of usage examples for com.liferay.portal.kernel.util ListUtil isEmpty

Introduction

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

Prototype

public static boolean isEmpty(List<?> list) 

Source Link

Usage

From source file:com.bemis.portal.order.service.impl.OrderRequestLocalServiceImpl.java

License:Open Source License

@Override
public void updateOrderRequests(long orderId, List<OrderRequest> orderRequests) throws PortalException {

    // Delete all existing OrderRequest

    orderRequestPersistence.removeByOrderId(orderId);

    // Add new OrderRequest list

    double requestedQty = 0;

    if (!ListUtil.isEmpty(orderRequests)) {
        for (OrderRequest orderRequest : orderRequests) {
            addOrderRequest(orderId, 0, orderRequest.getConfirmedQty(), orderRequest.getRequestedDate(),
                    orderRequest.getMaterialAvailDate());
        }/*from  w w  w .j  a v  a  2 s.c om*/

        // Calculate requestedQty

        requestedQty = orderRequests.stream().mapToDouble(orderRequest -> orderRequest.getRequestedQty()).sum();
    }

    // Update requestedQty in Order;

    resetTotalOrderedQty(orderId, requestedQty);
}

From source file:com.liferay.asset.categories.admin.web.internal.exportimport.staged.model.repository.StagedAssetLinkStagedModelRepository.java

License:Open Source License

protected AssetEntry fetchAssetEntry(long groupId, String uuid) throws PortalException {

    DynamicQuery dynamicQuery = _assetEntryLocalService.dynamicQuery();

    Property classUuidProperty = PropertyFactoryUtil.forName("classUuid");

    dynamicQuery.add(classUuidProperty.eq(uuid));

    List<AssetEntry> assetEntries = _assetEntryLocalService.dynamicQuery(dynamicQuery);

    if (ListUtil.isEmpty(assetEntries)) {
        return null;
    }/*from   w ww.jav a2 s .c om*/

    Map<Long, AssetEntry> assetEntryMap = new HashMap<>();

    for (AssetEntry assetEntry : assetEntries) {
        assetEntryMap.put(assetEntry.getGroupId(), assetEntry);
    }

    // Try to fetch the existing staged model from the importing group

    if (assetEntryMap.containsKey(groupId)) {
        return assetEntryMap.get(groupId);
    }

    // Try to fetch the existing staged model from parent sites

    Group group = _groupLocalService.getGroup(groupId);

    Group parentGroup = group.getParentGroup();

    while (parentGroup != null) {
        if (assetEntryMap.containsKey(parentGroup.getGroupId())) {
            AssetEntry assetEntry = assetEntryMap.get(parentGroup.getGroupId());

            if (isAssetEntryApplicable(assetEntry)) {
                return assetEntry;
            }
        }

        parentGroup = parentGroup.getParentGroup();
    }

    // Try to fetch the existing staged model from the global site

    Group companyGroup = _groupLocalService.fetchCompanyGroup(group.getCompanyId());

    if (assetEntryMap.containsKey(companyGroup.getGroupId())) {
        return assetEntryMap.get(companyGroup.getGroupId());
    }

    // Try to fetch the existing staged model from the company

    Stream<AssetEntry> assetEntryStream = assetEntries.stream();

    List<AssetEntry> companyAssetEntries = assetEntryStream
            .filter(entry -> entry.getCompanyId() == group.getCompanyId()).collect(Collectors.toList());

    if (ListUtil.isEmpty(companyAssetEntries)) {
        return null;
    }

    for (AssetEntry assetEntry : companyAssetEntries) {
        try {
            if (isAssetEntryApplicable(assetEntry)) {
                return assetEntry;
            }
        } catch (PortalException pe) {
            if (_log.isDebugEnabled()) {
                _log.debug(pe, pe);
            }
        }
    }

    return null;
}

From source file:com.liferay.calendar.lar.CalendarBookingStagedModelDataHandler.java

License:Open Source License

@Override
public CalendarBooking fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<CalendarBooking> calendarBookings = CalendarBookingLocalServiceUtil
            .getCalendarBookingsByUuidAndCompanyId(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    new StagedModelModifiedDateComparator<CalendarBooking>());

    if (ListUtil.isEmpty(calendarBookings)) {
        return null;
    }/*  ww  w.ja v a  2 s . c  o m*/

    return calendarBookings.get(0);
}

From source file:com.liferay.calendar.lar.CalendarNotificationTemplateStagedModelDataHandler.java

License:Open Source License

@Override
public CalendarNotificationTemplate fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<CalendarNotificationTemplate> calendarNotificationTemplates = CalendarNotificationTemplateLocalServiceUtil
            .getCalendarNotificationTemplatesByUuidAndCompanyId(uuid, companyId, QueryUtil.ALL_POS,
                    QueryUtil.ALL_POS, new StagedModelModifiedDateComparator<CalendarNotificationTemplate>());

    if (ListUtil.isEmpty(calendarNotificationTemplates)) {
        return null;
    }//from   w ww. j  ava 2  s.co  m

    return calendarNotificationTemplates.get(0);
}

From source file:com.liferay.calendar.lar.CalendarResourceStagedModelDataHandler.java

License:Open Source License

@Override
public CalendarResource fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<CalendarResource> calendarResources = CalendarResourceLocalServiceUtil
            .getCalendarResourcesByUuidAndCompanyId(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    new StagedModelModifiedDateComparator<CalendarResource>());

    if (ListUtil.isEmpty(calendarResources)) {
        return null;
    }//from  w  w w.j a va2s  .  co m

    return calendarResources.get(0);
}

From source file:com.liferay.calendar.lar.CalendarStagedModelDataHandler.java

License:Open Source License

@Override
public Calendar fetchStagedModelByUuidAndCompanyId(String uuid, long companyId) {

    List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarsByUuidAndCompanyId(uuid, companyId,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, new StagedModelModifiedDateComparator<Calendar>());

    if (ListUtil.isEmpty(calendars)) {
        return null;
    }/*from  w  ww .j  a  v a2s  .  co m*/

    return calendars.get(0);
}

From source file:com.liferay.dynamic.data.mapping.form.evaluator.impl.internal.DDMFormEvaluatorHelper.java

License:Open Source License

protected DDMFormFieldValue getDDMFormFieldValue(String ddmFormFieldName, String instanceId) {

    List<DDMFormFieldValue> ddmFormFieldValues = _ddmFormFieldValuesMap.get(ddmFormFieldName);

    if (ListUtil.isEmpty(ddmFormFieldValues)) {
        return null;
    }/*from   w  ww .j  a v a  2  s .  c  om*/

    for (DDMFormFieldValue ddmFormFieldValue : ddmFormFieldValues) {
        if (instanceId.equals(ddmFormFieldValue.getInstanceId())) {
            return ddmFormFieldValue;
        }

        for (DDMFormFieldValue nestedDDMFormFieldValue : ddmFormFieldValue.getNestedDDMFormFieldValues()) {

            if (instanceId.equals(nestedDDMFormFieldValue.getInstanceId())) {

                return nestedDDMFormFieldValue;
            }
        }
    }

    return null;
}

From source file:com.liferay.dynamic.data.mapping.form.evaluator.impl.internal.functions.CallFunction.java

License:Open Source License

protected void setDDMFormFieldValues(DDMDataProviderResponse ddmDataProviderResponse,
        Map<String, Object> resultMap, Map<String, String[]> outputParameterNameToPathsMap) {

    List<Map<Object, Object>> data = ddmDataProviderResponse.getData();

    if (ListUtil.isEmpty(data)) {
        return;//from w  w  w .j  av  a 2s  .c  om
    }

    for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
        String ddmFormFieldName = entry.getKey();

        Object value = entry.getValue();

        if (value instanceof JSONObject) {
            JSONObject jsonObject = (JSONObject) value;

            setDDMFormFieldOptions(data, ddmFormFieldName, jsonObject.getString("key"),
                    jsonObject.getString("value"));
        } else {
            String propertyName = getPropertyName(String.valueOf(value), outputParameterNameToPathsMap);

            setDDMFormFieldValue(data.get(0), ddmFormFieldName, propertyName);
        }
    }
}

From source file:com.liferay.dynamic.data.mapping.form.renderer.internal.DDMFormPagesTemplateContextFactory.java

License:Open Source License

public DDMFormPagesTemplateContextFactory(DDMForm ddmForm, DDMFormLayout ddmFormLayout,
        DDMFormRenderingContext ddmFormRenderingContext) {

    _ddmForm = ddmForm;//from ww  w.ja  v  a2 s  .  com
    _ddmFormLayout = ddmFormLayout;
    _ddmFormRenderingContext = ddmFormRenderingContext;

    DDMFormValues ddmFormValues = ddmFormRenderingContext.getDDMFormValues();

    if ((ddmFormValues == null) || ListUtil.isEmpty(ddmFormValues.getDDMFormFieldValues())) {

        DefaultDDMFormValuesFactory defaultDDMFormValuesFactory = new DefaultDDMFormValuesFactory(ddmForm,
                ddmFormRenderingContext.getLocale());

        ddmFormValues = defaultDDMFormValuesFactory.create();
    } else {
        removeStaleDDMFormFieldValues(ddmForm.getDDMFormFieldsMap(true), ddmFormValues.getDDMFormFieldValues());
    }

    _ddmFormValues = ddmFormValues;

    _ddmFormFieldsMap = ddmForm.getDDMFormFieldsMap(true);
    _ddmFormFieldValuesMap = ddmFormValues.getDDMFormFieldValuesMap();
    _locale = ddmFormRenderingContext.getLocale();
}

From source file:com.liferay.dynamic.data.mapping.form.web.internal.portlet.action.util.DDMFormInstanceFieldSettingsValidator.java

License:Open Source License

protected Set<String> getInvalidDDMFormFields(DDMForm fieldDDMForm,
        DDMFormEvaluationResult ddmFormEvaluationResult, Locale locale) {

    List<DDMFormFieldEvaluationResult> ddmFormFieldEvaluationResults = ddmFormEvaluationResult
            .getDDMFormFieldEvaluationResults();

    if (ListUtil.isEmpty(ddmFormFieldEvaluationResults)) {
        return Collections.emptySet();
    }/*from  www  . ja  va 2  s  .c om*/

    Set<String> ddmFormFieldList = new HashSet<>();

    Map<String, DDMFormField> ddmFormFieldsMap = fieldDDMForm.getDDMFormFieldsMap(true);

    Stream<DDMFormFieldEvaluationResult> stream = ddmFormFieldEvaluationResults.parallelStream();

    stream.forEach(fieldEvaluationResult -> {
        if (!fieldEvaluationResult.isValid()) {
            DDMFormField propertyFormField = ddmFormFieldsMap.get(fieldEvaluationResult.getName());

            ddmFormFieldList.add(getFieldLabel(propertyFormField, locale));
        }
    });

    return ddmFormFieldList;
}