use of org.apereo.portal.portlet.marketplace.IMarketplaceRating in project uPortal by Jasig.
the class MarketplaceRESTController method getUserRating.
@RequestMapping(value = "/marketplace/{fname}/getRating", method = RequestMethod.GET)
public ModelAndView getUserRating(HttpServletRequest request, @PathVariable String fname) {
Validate.notNull(fname, "Please supply a portlet to get rating for - should not be null");
IMarketplaceRating tempRating = marketplaceRatingDAO.getRating(request.getRemoteUser(), marketplaceService.getOrCreateMarketplacePortletDefinitionIfTheFnameExists(fname));
if (tempRating != null) {
return new ModelAndView("json", "rating", new MarketplaceEntryRating(tempRating.getRating(), tempRating.getReview()));
}
return new ModelAndView("json", "rating", null);
}
use of org.apereo.portal.portlet.marketplace.IMarketplaceRating in project uPortal by Jasig.
the class JpaMarketplaceRatingDao method getRatingsByFname.
/**
* @since 5.0
* @param marketplaceRatingPK the primary key of the entity you want
* @return Set of ratings per portlet definition
*/
@PortalTransactionalReadOnly
@OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)
public Set<IMarketplaceRating> getRatingsByFname(String fname) {
// Build criteria to fetch MarketplaceRatingImpl based on the incoming portlet name.
final EntityManager entityManager = this.getEntityManager();
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<IMarketplaceRating> getByPortlet = cb.createQuery(IMarketplaceRating.class);
final Root<MarketplaceRatingImpl> imr = getByPortlet.from(MarketplaceRatingImpl.class);
getByPortlet.select(imr);
// Define the path to the portlet fName
final Path<MarketplaceRatingPK> mrPK = imr.get("marketplaceRatingPK");
final Path<PortletDefinitionImpl> mrIPD = mrPK.get("portletDefinition");
final ParameterExpression<String> portletFName = cb.parameter(String.class, "portletFName");
getByPortlet.where(cb.equal(mrIPD.get("fname"), portletFName));
TypedQuery<IMarketplaceRating> tq = entityManager.createQuery(getByPortlet);
tq.setParameter("portletFName", fname);
List<IMarketplaceRating> resultList = tq.getResultList();
Set<IMarketplaceRating> resultSet = new HashSet<IMarketplaceRating>(resultList);
return resultSet;
}
Aggregations