Example usage for com.liferay.portal.kernel.util ArrayUtil containsAll

List of usage examples for com.liferay.portal.kernel.util ArrayUtil containsAll

Introduction

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

Prototype

public static boolean containsAll(short[] array1, short[] array2) 

Source Link

Usage

From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java

License:Open Source License

private static List<AssetEntry> _filterAssetCategoriesAssetEntries(List<AssetEntry> assetEntries,
        long[] assetCategoryIds) {

    List<AssetEntry> filteredAssetEntries = new ArrayList<>();

    for (AssetEntry assetEntry : assetEntries) {
        if (ArrayUtil.containsAll(assetEntry.getCategoryIds(), assetCategoryIds)) {

            filteredAssetEntries.add(assetEntry);
        }/*from  w w w  .  jav a 2 s . c  o  m*/
    }

    return filteredAssetEntries;
}

From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java

License:Open Source License

private static List<AssetEntry> _filterAssetTagNamesAssetEntries(List<AssetEntry> assetEntries,
        String[] assetTagNames) {

    List<AssetEntry> filteredAssetEntries = new ArrayList<>();

    for (AssetEntry assetEntry : assetEntries) {
        List<AssetTag> assetTags = assetEntry.getTags();

        String[] assetEntryAssetTagNames = new String[assetTags.size()];

        for (int i = 0; i < assetTags.size(); i++) {
            AssetTag assetTag = assetTags.get(i);

            assetEntryAssetTagNames[i] = assetTag.getName();
        }//from w w  w  .  j a va2s .c om

        if (ArrayUtil.containsAll(assetEntryAssetTagNames, assetTagNames)) {
            filteredAssetEntries.add(assetEntry);
        }
    }

    return filteredAssetEntries;
}

From source file:com.liferay.content.targeting.portlet.util.UserSegmentQueryRule.java

License:Open Source License

public boolean evaluate(long[] userSegmentAssetCategoryIds) {
    if (isDefaultRule()) {
        return true;
    }/*w w w . j  a  v a  2s . c om*/

    if (_contains) {
        if (_andOperator) {
            return ArrayUtil.containsAll(userSegmentAssetCategoryIds, _userSegmentAssetCategoryIds);
        }

        for (long userSegmentAssetCategoryId : _userSegmentAssetCategoryIds) {

            if (ArrayUtil.contains(userSegmentAssetCategoryIds, userSegmentAssetCategoryId)) {

                return true;
            }
        }

        return false;
    }

    if (_andOperator) {
        for (long userSegmentAssetCategoryId : _userSegmentAssetCategoryIds) {

            if (ArrayUtil.contains(userSegmentAssetCategoryIds, userSegmentAssetCategoryId)) {

                return false;
            }
        }

        return true;
    }

    for (long userSegmentAssetCategoryId : _userSegmentAssetCategoryIds) {
        if (!ArrayUtil.contains(userSegmentAssetCategoryIds, userSegmentAssetCategoryId)) {

            return true;
        }
    }

    return false;
}

From source file:com.liferay.contenttargeting.portlet.util.UserSegmentQueryRule.java

License:Open Source License

public boolean evaluate(long[] userSegmentAssetCategoryIds) {
    if (_contains) {
        if (_andOperator) {
            return ArrayUtil.containsAll(_userSegmentAssetCategoryIds, userSegmentAssetCategoryIds);
        } else {//from  ww  w . ja  v  a  2  s  .  co m
            for (long userSegmentAssetCategoryId : userSegmentAssetCategoryIds) {

                if (ArrayUtil.contains(_userSegmentAssetCategoryIds, userSegmentAssetCategoryId)) {

                    return true;
                }
            }

            return false;
        }
    } else {
        if (_andOperator) {
            for (long userSegmentAssetCategoryId : userSegmentAssetCategoryIds) {

                if (ArrayUtil.contains(_userSegmentAssetCategoryIds, userSegmentAssetCategoryId)) {

                    return false;
                }
            }

            return true;
        } else {
            for (long userSegmentAssetCategoryId : userSegmentAssetCategoryIds) {

                if (!ArrayUtil.contains(_userSegmentAssetCategoryIds, userSegmentAssetCategoryId)) {

                    return true;
                }
            }

            return false;
        }
    }
}

From source file:com.liferay.so.activities.hook.events.StartupAction.java

License:Open Source License

protected void initSocialActivityInterpreters() {
    List<SocialActivityInterpreter> activityInterpreters = SocialActivityInterpreterLocalServiceUtil
            .getActivityInterpreters("SO");

    String[] portletIds = PortletPropsValues.SOCIAL_ACTIVITY_INTERPRETER_PORTLET_IDS;

    for (String portletId : portletIds) {
        Filter filter = new Filter(portletId);

        String activityInterpreterClassName = PortletProps.get(PortletPropsKeys.SOCIAL_ACTIVITY_INTERPRETER,
                filter);/*from  www .  j a  v a2 s .co m*/

        try {
            SocialActivityInterpreter activityInterpreter = (SocialActivityInterpreter) InstanceFactory
                    .newInstance(activityInterpreterClassName);

            activityInterpreter = new SocialActivityInterpreterImpl(portletId, activityInterpreter);

            if (activityInterpreters != null) {
                for (SocialActivityInterpreter curActivityInterpreter : activityInterpreters) {

                    if (ArrayUtil.containsAll(activityInterpreter.getClassNames(),
                            curActivityInterpreter.getClassNames())) {

                        SocialActivityInterpreterLocalServiceUtil
                                .deleteActivityInterpreter(curActivityInterpreter);

                        break;
                    }
                }
            }

            SocialActivityInterpreterLocalServiceUtil.addActivityInterpreter(activityInterpreter);
        } catch (Exception e) {
            if (_log.isWarnEnabled()) {
                _log.warn("Unable to add social activity interpreter " + activityInterpreterClassName);
            }
        }
    }
}