Example usage for com.liferay.portal.kernel.util PrimitiveLongList addAll

List of usage examples for com.liferay.portal.kernel.util PrimitiveLongList addAll

Introduction

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

Prototype

public void addAll(long[] values) 

Source Link

Usage

From source file:com.liferay.asset.entry.query.processor.custom.user.attributes.internal.CustomUserAttributesAssetEntryQueryProcessor.java

License:Open Source License

private void _addUserAttributes(User user, String[] customUserAttributeNames, AssetEntryQuery assetEntryQuery) {

    if ((user == null) || (customUserAttributeNames.length == 0)) {
        return;/*from  w  w  w.ja  v a 2s.c  o m*/
    }

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

    long[] allCategoryIds = assetEntryQuery.getAllCategoryIds();

    PrimitiveLongList allCategoryIdsList = new PrimitiveLongList(
            allCategoryIds.length + customUserAttributeNames.length);

    allCategoryIdsList.addAll(allCategoryIds);

    for (String customUserAttributeName : customUserAttributeNames) {
        ExpandoBridge userCustomAttributes = user.getExpandoBridge();

        Serializable userCustomFieldValue = userCustomAttributes.getAttribute(customUserAttributeName);

        if (userCustomFieldValue == null) {
            continue;
        }

        String userCustomFieldValueString = userCustomFieldValue.toString();

        List<AssetCategory> assetCategories = _assetCategoryLocalService.search(companyGroup.getGroupId(),
                userCustomFieldValueString, new String[0], QueryUtil.ALL_POS, QueryUtil.ALL_POS);

        for (AssetCategory assetCategory : assetCategories) {
            allCategoryIdsList.add(assetCategory.getCategoryId());
        }
    }

    assetEntryQuery.setAllCategoryIds(allCategoryIdsList.getArray());
}

From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java

License:Open Source License

public static void addUserAttributes(User user, String[] customUserAttributeNames,
        AssetEntryQuery assetEntryQuery) {

    if ((user == null) || (customUserAttributeNames.length == 0)) {
        return;//  ww  w.  ja  v a  2 s . co m
    }

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

    long[] allCategoryIds = assetEntryQuery.getAllCategoryIds();

    PrimitiveLongList allCategoryIdsList = new PrimitiveLongList(
            allCategoryIds.length + customUserAttributeNames.length);

    allCategoryIdsList.addAll(allCategoryIds);

    for (String customUserAttributeName : customUserAttributeNames) {
        ExpandoBridge userCustomAttributes = user.getExpandoBridge();

        Serializable userCustomFieldValue = userCustomAttributes.getAttribute(customUserAttributeName);

        if (userCustomFieldValue == null) {
            continue;
        }

        String userCustomFieldValueString = userCustomFieldValue.toString();

        List<AssetCategory> assetCategories = _assetCategoryLocalService.search(companyGroup.getGroupId(),
                userCustomFieldValueString, new String[0], QueryUtil.ALL_POS, QueryUtil.ALL_POS);

        for (AssetCategory assetCategory : assetCategories) {
            allCategoryIdsList.add(assetCategory.getCategoryId());
        }
    }

    assetEntryQuery.setAllCategoryIds(allCategoryIdsList.getArray());
}

From source file:com.liferay.portlet.assetpublisher.util.AssetPublisherUtil.java

License:Open Source License

public static void addUserAttributes(User user, String[] customUserAttributeNames,
        AssetEntryQuery assetEntryQuery) throws Exception {

    if ((user == null) || (customUserAttributeNames.length == 0)) {
        return;/*from  w w  w.j a  v a  2 s .  c o  m*/
    }

    Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(user.getCompanyId());

    long[] allCategoryIds = assetEntryQuery.getAllCategoryIds();

    PrimitiveLongList allCategoryIdsList = new PrimitiveLongList(
            allCategoryIds.length + customUserAttributeNames.length);

    allCategoryIdsList.addAll(allCategoryIds);

    for (String customUserAttributeName : customUserAttributeNames) {
        ExpandoBridge userCustomAttributes = user.getExpandoBridge();

        Serializable userCustomFieldValue = userCustomAttributes.getAttribute(customUserAttributeName);

        if (userCustomFieldValue == null) {
            continue;
        }

        String userCustomFieldValueString = userCustomFieldValue.toString();

        List<AssetCategory> assetCategories = AssetCategoryLocalServiceUtil.search(companyGroup.getGroupId(),
                userCustomFieldValueString, new String[0], QueryUtil.ALL_POS, QueryUtil.ALL_POS);

        for (AssetCategory assetCategory : assetCategories) {
            allCategoryIdsList.add(assetCategory.getCategoryId());
        }
    }

    assetEntryQuery.setAllCategoryIds(allCategoryIdsList.getArray());
}