Example usage for com.liferay.portal.kernel.model GroupedModel getGroupId

List of usage examples for com.liferay.portal.kernel.model GroupedModel getGroupId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model GroupedModel getGroupId.

Prototype

public long getGroupId();

Source Link

Usage

From source file:com.liferay.ratings.internal.page.ratings.exportimport.data.handler.PageRatingsPortletDataHandler.java

License:Open Source License

protected long getGroupId(RatingsEntry ratingsEntry) throws PortalException {

    PersistedModelLocalService persistedModelLocalService = PersistedModelLocalServiceRegistryUtil
            .getPersistedModelLocalService(ratingsEntry.getClassName());

    if (persistedModelLocalService == null) {
        return GroupConstants.DEFAULT_PARENT_GROUP_ID;
    }// w ww  .  j av  a  2s.  c o m

    PersistedModel persistedModel = null;

    try {
        persistedModel = persistedModelLocalService.getPersistedModel(ratingsEntry.getClassPK());
    } catch (NoSuchModelException nsme) {
        if (_log.isDebugEnabled()) {
            _log.debug(nsme.getMessage(), nsme);
        }

        return GroupConstants.DEFAULT_PARENT_GROUP_ID;
    }

    if (!(persistedModel instanceof GroupedModel)) {
        return GroupConstants.DEFAULT_PARENT_GROUP_ID;
    }

    GroupedModel groupedModel = (GroupedModel) persistedModel;

    return groupedModel.getGroupId();
}