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

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

Introduction

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

Prototype

public void add(long value) 

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 .  j  av  a2s  .  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;/*from w  w  w .ja va  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.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;/*  www  .  j a  v a2 s . co  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());
}