Package de.hybris.platform.order
Interface AbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>
-
- All Known Subinterfaces:
B2BCartService,B2BOrderService,CartService,OrderService
- All Known Implementing Classes:
DefaultAbstractOrderService,DefaultAlipayOrderService,DefaultB2BCartService,DefaultB2BOrderService,DefaultCartService,DefaultCartServiceForAccelerator,DefaultChineseOrderService,DefaultOrderService,DefaultWeChatPayOrderService
public interface AbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>Abstract interface for services dedicated for handling subtypes ofAbstractOrderModel. Extend this service with a typed interface (likeOrderService, orCartService) to obtain a set of it's contract methods for your type (likeOrderModel, orCartModelcorrespondingly). Default implementation -DefaultAbstractOrderService- provides shared implementation on theAbstractOrderModel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAllGlobalDiscountValues(O order, java.util.List<DiscountValue> discountValues)Adds a collection of global discount values to the given order.voidaddAllTotalTaxValues(O order, java.util.List<TaxValue> taxValues)Adds a collection of tax values into given order.voidaddGlobalDiscountValue(O order, DiscountValue discountValue)Adds a global discount value to the given order.AbstractOrderEntryModeladdNewEntry(ComposedTypeModel entryType, O order, ProductModel product, long qty, UnitModel unit, int number, boolean addToPresent)Adds a new entry of the givenComposedTypeModelto the given order.EaddNewEntry(O order, ProductModel product, long qty, UnitModel unit)Adds a new entry to the given order.EaddNewEntry(O order, ProductModel product, long qty, UnitModel unit, int number, boolean addToPresent)Adds a new entry to the given order on the required entry number.voidaddTotalTaxValue(O order, TaxValue taxValue)Convenience method to add aTaxValueto the given order.Oclone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, java.lang.String code)Creates new order from given original and change its type and type for entry.java.util.List<E>getEntriesForNumber(O order, int start, int end)Returns order entries with the givenAbstractOrderEntryModel.ENTRYNUMBER.java.util.List<E>getEntriesForProduct(O order, ProductModel product)Returns order entries having the target product.EgetEntryForNumber(O order, int number)Returns an order entry with the givenAbstractOrderEntryModel.ENTRYNUMBER.DiscountValuegetGlobalDiscountValue(O order, DiscountValue discountValue)Searches for complete discount value (with calculated applied value) object created using given discountValue.voidremoveGlobalDiscountValue(O order, DiscountValue discountValue)Removes a global discount value from this order.voidremoveTotalTaxValue(O order, TaxValue taxValue)Removes a tax value from the given order.OsaveOrder(O order)Persist the model and all it's members and entries within one transaction usingSaveAbstractOrderStrategy.
-
-
-
Method Detail
-
addNewEntry
E addNewEntry(O order, ProductModel product, long qty, UnitModel unit)
Adds a new entry to the given order. The entry type is recognized basing onAbstractOrderEntryTypeServiceand the spring configuration behind it. When a product already exists, the corresponding entry quantity is increased. If a null Unit is specified, a unit according to given product will be chosen. The new entry is neither saved nor calculated.- Parameters:
order- - target orderproduct- -product to add, must not be nullqty- - quantityunit- - must not be null- Returns:
AbstractOrderEntryModel- newly created order entry- Throws:
java.lang.IllegalArgumentException- if either order or product is null or quantity is negative- See Also:
AbstractOrderEntryTypeService.getAbstractOrderEntryType(AbstractOrderModel)
-
addNewEntry
E addNewEntry(O order, ProductModel product, long qty, UnitModel unit, int number, boolean addToPresent)
Adds a new entry to the given order on the required entry number. The entry type is recognized basing onAbstractOrderEntryTypeServiceand the spring configuration behind it. The new entry is neither saved nor calculated. If your new entry has caused entries shuffling you may need to callsaveOrder(AbstractOrderModel)method in order to persist the changes.- Parameters:
order- - target orderproduct- -product to add, must not be nullqty- - quantityunit- - must not be nullnumber- - entry number of the new entry in the order. Entries are indexed starting from 0. Set number to -1 if you want to append the entry as the last one. You can request any non-negative position.addToPresent- - if true an existing entry with matching product and unit will get its quantity increased; otherwise a new entry is created- Returns:
AbstractOrderEntryModel- newly created order entry- Throws:
java.lang.IllegalArgumentException- if either order or product is null or quantity is negative.- See Also:
AbstractOrderEntryTypeService.getAbstractOrderEntryType(AbstractOrderModel)
-
addNewEntry
AbstractOrderEntryModel addNewEntry(ComposedTypeModel entryType, O order, ProductModel product, long qty, UnitModel unit, int number, boolean addToPresent)
Adds a new entry of the givenComposedTypeModelto the given order. The new entry is neither saved nor calculated. If your new entry has caused entries shuffling you may need to callsaveOrder(AbstractOrderModel)method in order to persist the changes.- Parameters:
entryType- - the requested sub-type AbstractOrderEntryorder- - target orderproduct- -product to add, must not be nullqty- - quantityunit- - must not be nullnumber- - entry number of the new entry in the order. Entries are indexed starting from 0. Set number to -1 if you want to append the entry as the last one. You can request any non-negative position.addToPresent- - if true an existing entry with matching product and unit will get its quantity increased; otherwise a new entry is created- Returns:
AbstractOrderEntryModel- newly created order entry- Throws:
java.lang.IllegalArgumentException- if either entryType or order or product is null or quantity is negative.
-
clone
O clone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, java.lang.String code)
Creates new order from given original and change its type and type for entry. Delegates to the specificCloneAbstractOrderStrategyinjected strategy. Resulting order remains not persisted.- Parameters:
orderType- type of result order (OrderModel will be chosen if null is passed)entryType- type of entry (if null will use service to get proper type)original- original ordercode- code for new order- Returns:
- not persisted order model instance.
-
getEntryForNumber
E getEntryForNumber(O order, int number)
Returns an order entry with the givenAbstractOrderEntryModel.ENTRYNUMBER. The method delegates to data access object and checks the actual persisted order in the data base, not the order state represented by the model.- Parameters:
order-number-- Returns:
AbstractOrderEntryModel- Throws:
UnknownIdentifierException- if no entry with the requested number existsjava.lang.IllegalArgumentException- if either order is null or number is negative
-
getEntriesForNumber
java.util.List<E> getEntriesForNumber(O order, int start, int end)
Returns order entries with the givenAbstractOrderEntryModel.ENTRYNUMBER. The method delegates to data access object and checks the actual persisted order in the data base, not the order state represented by the model.- Parameters:
order-start- start of the rangeend- end of the range- Returns:
AbstractOrderEntryModel- Throws:
UnknownIdentifierException- if no entry from the requested range number existsjava.lang.IllegalArgumentException- if either order is null or start is negative or start is greater than end
-
getEntriesForProduct
java.util.List<E> getEntriesForProduct(O order, ProductModel product)
Returns order entries having the target product. In case is no entry contains the requested product, empty list is returned. The method delegates to data access object and checks the actual persisted order in the data base, not the order state represented by the model.- Parameters:
order- - target orderproduct- - searched product- Returns:
- matching order entries
- Throws:
java.lang.IllegalArgumentException- if either order or product is null
-
saveOrder
O saveOrder(O order)
Persist the model and all it's members and entries within one transaction using
This method is useful if you have added anSaveAbstractOrderStrategy. After this method call the order and it's entries are refreshed.AbstractOrderEntryModelon the already occupied entryNumber position, which caused order entries shuffling. In other, trivial cases, the regular call toModelService.save(Object)is sufficient. Please mind that the concrete typed service must allow entries shuffling (likeCartServicedoes). Tying to put OrderEntryModel on an occupied entryNumber usingOrderServicewould throw an exception in the first place.The method call is delegated to the spring configurable
SaveAbstractOrderStrategy.- Parameters:
order- - non persistedOrderModelthat needs to be persisted.- Returns:
- persisted
OrderModel - Throws:
java.lang.IllegalArgumentException- if order is null.
-
addTotalTaxValue
void addTotalTaxValue(O order, TaxValue taxValue)
Convenience method to add aTaxValueto the given order. please note that the order's tax values are overwritten each timeCalculationService.calculate(AbstractOrderModel),CalculationService.calculate(AbstractOrderModel, java.util.Date),CalculationService.recalculate(AbstractOrderModel),CalculationService.recalculate(AbstractOrderModel, java.util.Date)is called. Those calls fetch the tax information from the price factory and overwrites the previous state. The content of theAbstractOrderModel.TOTALTAXVALUESrepresents all tax values introduced by the order entries. After this method call, the order model remains not persisted.- Parameters:
taxValue-order- target order- Throws:
java.lang.IllegalArgumentException- if eitherorderortaxValueis null.
-
addAllTotalTaxValues
void addAllTotalTaxValues(O order, java.util.List<TaxValue> taxValues)
Adds a collection of tax values into given order. please note that this field is overwritten each timeCalculationService.calculate(AbstractOrderModel),CalculationService.calculate(AbstractOrderModel, java.util.Date),CalculationService.recalculate(AbstractOrderModel),CalculationService.recalculate(AbstractOrderModel, java.util.Date)is called. Those calls fetch the tax information from the price factory and overwrites the previous state. The content of theAbstractOrderModel.TOTALTAXVALUESrepresents all tax values introduced by the order entries. After this method call, the order model remains not persisted.- Parameters:
order- target ordertaxValues- tax values to add- Throws:
java.lang.IllegalArgumentException- if eitherorderortaxValuesis null.
-
removeTotalTaxValue
void removeTotalTaxValue(O order, TaxValue taxValue)
Removes a tax value from the given order. please note that this field will be overwritten after one of the following method calls:CalculationService.calculate(AbstractOrderModel),CalculationService.calculate(AbstractOrderModel, java.util.Date),CalculationService.recalculate(AbstractOrderModel),CalculationService.recalculate(AbstractOrderModel, java.util.Date)is called. Those calls fetch the tax information from the price factory and overwrites the previous state. The content of theAbstractOrderModel.TOTALTAXVALUESrepresents all tax values introduced by the order entries. After this method call, the order model remains not persisted.- Parameters:
taxValue-order- target order- Throws:
java.lang.IllegalArgumentException- if eitherorderortaxValueis null.
-
addGlobalDiscountValue
void addGlobalDiscountValue(O order, DiscountValue discountValue)
Adds a global discount value to the given order. Such discount will be treated globally for the whole order rather than for any particular entry. After this method call order remains not persisted. User needs to manually persist and recalculate the order so that the global discount is reflected in the total price.- Parameters:
discountValue- discount to addorder- target order- Throws:
java.lang.IllegalArgumentException- if eitherorderordiscountValueis null.
-
addAllGlobalDiscountValues
void addAllGlobalDiscountValues(O order, java.util.List<DiscountValue> discountValues)
Adds a collection of global discount values to the given order. Such discounts will be treated globally for the whole order rather than for any particular entry. After this method call order remains not persisted. User needs to manually persist and recalculate the order so that the added global discounts are reflected in the total price.- Parameters:
discountValues- discount values to addorder- target order- Throws:
java.lang.IllegalArgumentException- if eitherorderordiscountValuesis null.
-
removeGlobalDiscountValue
void removeGlobalDiscountValue(O order, DiscountValue discountValue)
Removes a global discount value from this order. After this method call order remains not persisted. User needs to manually persist and recalculate the order so that the added global discounts are reflected in the total price.- Parameters:
discountValue- discount to removeorder- target order- Throws:
java.lang.IllegalArgumentException- if eitherorderordiscountValueis null.
-
getGlobalDiscountValue
DiscountValue getGlobalDiscountValue(O order, DiscountValue discountValue)
Searches for complete discount value (with calculated applied value) object created using given discountValue. Returns null when discount value for given parameter can not be found.
-
-