Package org.ametys.plugins.cart
Class CartsDAO
java.lang.Object
org.ametys.plugins.cart.CartsDAO
- All Implemented Interfaces:
Component
,Serviceable
DAO for manipulating carts
-
Field Summary
Modifier and TypeFieldDescriptionprotected UserManager
The user managerstatic final String
The Avalon role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Test if the current user has the right needed by the content type to view this cart.Add elements to a cart.Adds users or groups to a cart profile.changeVisibility
(String cartId, String visibilityStr) Changes the visibility of a cart.createCart
(String title, String description) Creates a cart.deleteCarts
(List<String> ids) Deletes some carts.Deletes elements of a cart.Get the cart with given idgetCartProperties
(Cart cart) Get the cart type propertiesgetCartsInformation
(List<String> cartIds) Gets carts information.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) updateCart
(String id, String title, String description) Updates a cart.
-
Field Details
-
ROLE
The Avalon role -
_userManager
The user manager
-
-
Constructor Details
-
CartsDAO
public CartsDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCartsInformation
Gets carts information.- Parameters:
cartIds
- The ids of the carts to retrieve.- Returns:
- The carts information
-
createCart
Creates a cart.- Parameters:
title
- The titledescription
- The description- Returns:
- The id of the created cart
-
updateCart
Updates a cart.- Parameters:
id
- The id of the cart to updatetitle
- The titledescription
- The description- Returns:
- The id of the updated cart
-
deleteCarts
Deletes some carts.- Parameters:
ids
- The ids of the carts to delete- Returns:
- The ids of the deleted carts
-
addElements
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
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
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
Get the cart with given id- Parameters:
cartId
- The cart id- Returns:
- The retrieved cart or null.
-
getCartProperties
Get the cart type properties- Parameters:
cart
- The cart- Returns:
- The cart type properties
-
_hasRight
Test if the current user has the right needed by the content type to view this cart.- Parameters:
cart
- The cart- Returns:
- true if the user has the right needed, false otherwise.
-