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

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

Introduction

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

Prototype

public PrimitiveLongList(int capacity) 

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 ww  . j  a  v  a 2s.com*/
    }

    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;/* w  ww.  ja v  a 2 s. com*/
    }

    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;/*  w  w w .ja  va  2s . com*/
    }

    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());
}