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