Package org.ametys.plugins.cart
Class CartsDAO
- java.lang.Object
-
- org.ametys.plugins.cart.CartsDAO
-
- All Implemented Interfaces:
Component
,Serviceable
public class CartsDAO extends Object implements Serviceable, Component
DAO for manipulating carts
-
-
Field Summary
Fields Modifier and Type Field Description private AmetysObjectResolver
_resolver
The Ametys object resolverprivate UserHelper
_userHelper
protected UserManager
_userManager
The user managerprivate CurrentUserProvider
_userProvider
The current user providerstatic String
ROLE
The Avalon role
-
Constructor Summary
Constructors Constructor Description CartsDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_hasRight(Cart cart)
Test if the current user has the right needed by the content type to view this cart.Map<String,Object>
addElements(String cartId, String type, Map<String,Object> elementParams)
Add elements to a cart.Map<String,Object>
assignRights(String cartId, String profileId, List<Map<String,String>> entries, String type)
Adds users or groups to a cart profile.Map<String,Object>
changeVisibility(String cartId, String visibilityStr)
Changes the visibility of a cart.Map<String,String>
createCart(String title, String description)
Creates a cart.Map<String,Object>
deleteCarts(List<String> ids)
Deletes some carts.Map<String,Object>
deleteElements(String cartId, List<Map<String,String>> cartElements)
Deletes elements of a cart.Cart
getCart(String cartId)
Get the cart with given idMap<String,Object>
getCartProperties(Cart cart)
Get the cart type propertiesMap<String,Object>
getCartsInformation(List<String> cartIds)
Gets carts information.Map<String,Object>
removeAssignment(String cartId, String profileId, List<Map<String,String>> users, List<Map<String,String>> groups)
Deletes users or groups to a cart profile.void
service(ServiceManager serviceManager)
Map<String,String>
updateCart(String id, String title, String description)
Updates a cart.
-
-
-
Field Detail
-
_userManager
protected UserManager _userManager
The user manager
-
_userProvider
private CurrentUserProvider _userProvider
The current user provider
-
_resolver
private AmetysObjectResolver _resolver
The Ametys object resolver
-
_userHelper
private UserHelper _userHelper
-
-
Constructor Detail
-
CartsDAO
public CartsDAO()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCartsInformation
public Map<String,Object> getCartsInformation(List<String> cartIds)
Gets carts information.- Parameters:
cartIds
- The ids of the carts to retrieve.- Returns:
- The carts information
-
createCart
public Map<String,String> createCart(String title, String description)
Creates a cart.- Parameters:
title
- The titledescription
- The description- Returns:
- The id of the created cart
-
updateCart
public Map<String,String> updateCart(String id, String title, String description)
Updates a cart.- Parameters:
id
- The id of the cart to updatetitle
- The titledescription
- The description- Returns:
- The id of the updated cart
-
deleteCarts
public Map<String,Object> deleteCarts(List<String> ids)
Deletes some carts.- Parameters:
ids
- The ids of the carts to delete- Returns:
- The ids of the deleted carts
-
addElements
public Map<String,Object> addElements(String cartId, String type, Map<String,Object> elementParams)
Add elements to a cart.- Parameters:
cartId
- The cart id.type
- The type of element.elementParams
- The parameters of the element.- Returns:
- The id of the cart or an error
-
deleteElements
public Map<String,Object> deleteElements(String cartId, List<Map<String,String>> cartElements)
Deletes elements of a cart.- Parameters:
cartId
- The cart id.cartElements
- The elements to delete.- Returns:
- The id of the cart or an error
-
changeVisibility
public Map<String,Object> changeVisibility(String cartId, String visibilityStr)
Changes the visibility of a cart.- Parameters:
cartId
- The cart id.visibilityStr
- The visibility to set.- Returns:
- An empty map, or an error message.
-
assignRights
public Map<String,Object> assignRights(String cartId, String profileId, List<Map<String,String>> entries, String type)
Adds users or groups to a cart profile.- Parameters:
cartId
- The cart id.profileId
- The profile id.entries
- The users (or groups) entries.type
- The type of the entries to add: 'users' or 'groups'- Returns:
- An empty map, or an error.
-
removeAssignment
public Map<String,Object> removeAssignment(String cartId, String profileId, List<Map<String,String>> users, List<Map<String,String>> groups)
Deletes users or groups to a cart profile.- Parameters:
cartId
- The cart id.profileId
- The profile id.users
- The users to delete.groups
- The groups to delete;- Returns:
- An empty map, or an error.
-
getCart
public Cart getCart(String cartId)
Get the cart with given id- Parameters:
cartId
- The cart id- Returns:
- The retrieved cart or null.
-
getCartProperties
public Map<String,Object> getCartProperties(Cart cart)
Get the cart type properties- Parameters:
cart
- The cart- Returns:
- The cart type properties
-
-