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

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

Introduction

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

Prototype

public long[] getArray() 

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 a 2 s  .  c  om
    }

    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 w w. j a  v a2 s.  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;//from  w  w w  .  ja va  2  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());
}