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 protected UserManager
_userManager
The user managerstatic 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,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.boolean
hasReadRightOnCart(UserIdentity userIdentity, Cart cart)
Check if a user have read rights on a cartboolean
hasRightAffectationRightOnCart(UserIdentity userIdentity, Cart cart)
Check if a user have rights to edit rights on a cartboolean
hasWriteRightOnCart(UserIdentity userIdentity, Cart cart)
Check if a user have write rights on a cartvoid
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
-
-
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
-
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
-
_hasRight
protected boolean _hasRight(Cart cart)
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.
-
hasReadRightOnCart
public boolean hasReadRightOnCart(UserIdentity userIdentity, Cart cart)
Check if a user have read rights on a cart- Parameters:
userIdentity
- the usercart
- the cart- Returns:
- true if the user have read rights on a cart
-
hasWriteRightOnCart
public boolean hasWriteRightOnCart(UserIdentity userIdentity, Cart cart)
Check if a user have write rights on a cart- Parameters:
userIdentity
- the usercart
- the cart- Returns:
- true if the user have write rights on a cart
-
hasRightAffectationRightOnCart
public boolean hasRightAffectationRightOnCart(UserIdentity userIdentity, Cart cart)
Check if a user have rights to edit rights on a cart- Parameters:
userIdentity
- the usercart
- the cart- Returns:
- true if the user have write rights to edit rights on a cart
-
-