Search in sources :

Example 61 with IPortletEntity

use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.

the class TransientPortletEntityDao method getPortletEntity.

/* (non-Javadoc)
     * @see org.apereo.portal.portlet.dao.IPortletEntityDao#getPortletEntity(java.lang.String, int)
     */
@Override
public IPortletEntity getPortletEntity(String layoutNodeId, int userId) {
    if (layoutNodeId.startsWith(TransientUserLayoutManagerWrapper.SUBSCRIBE_PREFIX)) {
        final String databaseChannelSubscribeId = this.determineDatabaseChannelSubscribeId(layoutNodeId);
        final IPortletEntity portletEntity = this.delegatePortletEntityDao.getPortletEntity(databaseChannelSubscribeId, userId);
        return this.wrapEntity(portletEntity);
    }
    return this.delegatePortletEntityDao.getPortletEntity(layoutNodeId, userId);
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity)

Example 62 with IPortletEntity

use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.

the class JpaPortletEntityDao method getPortletEntity.

@Override
@DialectAwareTransactional(value = PostgreSQL81Dialect.class, exclude = false)
@PortalTransactionalReadOnly
@OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
public IPortletEntity getPortletEntity(String layoutNodeId, int userId) {
    Validate.notNull(layoutNodeId, "portletEntity can not be null");
    /* Since portal entities mostly are retrieved in batches (for each "channel" element in user's layout), it is
         * faster to retrieve all portlet entities, so that persistence framework can place them in 2nd level cache, and
         * iterate over them manually instead of retrieving single portlet entity one by one. */
    Set<IPortletEntity> entities = getPortletEntitiesForUser(userId);
    for (IPortletEntity entity : entities) {
        if (StringUtils.equals(entity.getLayoutNodeId(), layoutNodeId)) {
            return entity;
        }
    }
    return null;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) DialectAwareTransactional(org.apereo.portal.spring.tx.DialectAwareTransactional) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager)

Example 63 with IPortletEntity

use of org.apereo.portal.portlet.om.IPortletEntity in project uPortal by Jasig.

the class JpaPortletEntityDao method createPortletEntity.

@Override
@PortalTransactional
public IPortletEntity createPortletEntity(IPortletDefinitionId portletDefinitionId, String layoutNodeId, int userId) {
    Validate.notNull(portletDefinitionId, "portletDefinitionId can not be null");
    Validate.notEmpty(layoutNodeId, "layoutNodeId can not be null");
    final IPortletDefinition portletDefinition = this.portletDefinitionDao.getPortletDefinition(portletDefinitionId);
    if (portletDefinition == null) {
        throw new DataRetrievalFailureException("No IPortletDefinition exists for IPortletDefinitionId='" + portletDefinitionId + "'");
    }
    IPortletEntity portletEntity = new PortletEntityImpl(portletDefinition, layoutNodeId, userId);
    this.getEntityManager().persist(portletEntity);
    return portletEntity;
}
Also used : IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)63 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)32 IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)25 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)24 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)19 IUserInstance (org.apereo.portal.user.IUserInstance)12 Test (org.junit.Test)11 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)10 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)10 List (java.util.List)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 PortletPreferenceImpl (org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl)9 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)9 BasePortalJpaDaoTest (org.apereo.portal.test.BasePortalJpaDaoTest)9 IPerson (org.apereo.portal.security.IPerson)7 PortletApplicationDefinition (org.apache.pluto.container.om.portlet.PortletApplicationDefinition)5 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)5 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)5 ArrayList (java.util.ArrayList)4 Callable (java.util.concurrent.Callable)4