Package de.hybris.platform.order.impl
Class DefaultAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.order.impl.DefaultAbstractOrderService<O,E>
-
- All Implemented Interfaces:
AbstractOrderService<O,E>,java.io.Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
DefaultCartService,DefaultOrderService
public abstract class DefaultAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel> extends AbstractBusinessService implements AbstractOrderService<O,E>
Default implementation ofAbstractOrderService. Implements its contract on theAbstractOrderModeltype level. Any order related services should extend it (i.e.DefaultOrderService,DefaultCartService, or a dedicated service for a custom order type).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultAbstractOrderService()
-
Method Summary
All Methods Instance Methods Concrete 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.protected intaddEntryAtPosition(AbstractOrderModel order, AbstractOrderEntryModel entry, int requested)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.protected AbstractOrderEntryService<E>getAbstractOrderEntryService()protected AbstractOrderEntryTypeServicegetAbstractOrderEntryTypeService()protected CloneAbstractOrderStrategygetCloneAbstractOrderStrategy()protected AbstractOrderEntryModelgetCollidingEntry(int requested, O order)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.protected java.lang.StringgetEntryTypeCode(AbstractOrderModel order)DiscountValuegetGlobalDiscountValue(O order, DiscountValue discountValue)Searches for complete discount value (with calculated applied value) object created using given discountValue.protected OrderDaogetOrderDao()protected SaveAbstractOrderStrategy<O>getSaveAbstractOrderStrategy()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.voidsetAbstractOrderEntryService(AbstractOrderEntryService<E> abstractOrderEntryService)voidsetAbstractOrderEntryTypeService(AbstractOrderEntryTypeService abstractOrderEntryTypeService)voidsetCloneAbstractOrderStrategy(CloneAbstractOrderStrategy cloneAbstractOrderStrategy)voidsetOrderDao(OrderDao orderDao)voidsetSaveAbstractOrderStrategy(SaveAbstractOrderStrategy<O> saveAbstractOrderStrategy)-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.order.AbstractOrderService
clone
-
-
-
-
Method Detail
-
addNewEntry
public E addNewEntry(O order, ProductModel product, long qty, UnitModel unit)
Description copied from interface:AbstractOrderServiceAdds 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.- Specified by:
addNewEntryin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- - target orderproduct- -product to add, must not be nullqty- - quantityunit- - must not be null- Returns:
AbstractOrderEntryModel- newly created order entry- See Also:
AbstractOrderEntryTypeService.getAbstractOrderEntryType(AbstractOrderModel)
-
addNewEntry
public E addNewEntry(O order, ProductModel product, long qty, UnitModel unit, int number, boolean addToPresent)
Description copied from interface:AbstractOrderServiceAdds 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 callAbstractOrderService.saveOrder(AbstractOrderModel)method in order to persist the changes.- Specified by:
addNewEntryin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- 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- See Also:
AbstractOrderEntryTypeService.getAbstractOrderEntryType(AbstractOrderModel)
-
addNewEntry
public AbstractOrderEntryModel addNewEntry(ComposedTypeModel entryType, O order, ProductModel product, long qty, UnitModel unit, int number, boolean addToPresent)
Description copied from interface:AbstractOrderServiceAdds 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 callAbstractOrderService.saveOrder(AbstractOrderModel)method in order to persist the changes.- Specified by:
addNewEntryin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- 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
-
addEntryAtPosition
protected int addEntryAtPosition(AbstractOrderModel order, AbstractOrderEntryModel entry, int requested)
-
getEntryForNumber
public E getEntryForNumber(O order, int number)
Description copied from interface:AbstractOrderServiceReturns 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.- Specified by:
getEntryForNumberin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Returns:
AbstractOrderEntryModel
-
getEntriesForNumber
public java.util.List<E> getEntriesForNumber(O order, int start, int end)
Description copied from interface:AbstractOrderServiceReturns 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.- Specified by:
getEntriesForNumberin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>start- start of the rangeend- end of the range- Returns:
AbstractOrderEntryModel
-
getEntriesForProduct
public java.util.List<E> getEntriesForProduct(O order, ProductModel product)
Description copied from interface:AbstractOrderServiceReturns 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.- Specified by:
getEntriesForProductin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- - target orderproduct- - searched product- Returns:
- matching order entries
-
saveOrder
public O saveOrder(O order)
Description copied from interface:AbstractOrderServicePersist 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.- Specified by:
saveOrderin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- - non persistedOrderModelthat needs to be persisted.- Returns:
- persisted
OrderModel
-
addGlobalDiscountValue
public void addGlobalDiscountValue(O order, DiscountValue discountValue)
Description copied from interface:AbstractOrderServiceAdds 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.- Specified by:
addGlobalDiscountValuein interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- target orderdiscountValue- discount to add
-
addTotalTaxValue
public void addTotalTaxValue(O order, TaxValue taxValue)
Description copied from interface:AbstractOrderServiceConvenience 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.- Specified by:
addTotalTaxValuein interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- target order
-
addAllGlobalDiscountValues
public void addAllGlobalDiscountValues(O order, java.util.List<DiscountValue> discountValues)
Description copied from interface:AbstractOrderServiceAdds 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.- Specified by:
addAllGlobalDiscountValuesin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- target orderdiscountValues- discount values to add
-
addAllTotalTaxValues
public void addAllTotalTaxValues(O order, java.util.List<TaxValue> taxValues)
Description copied from interface:AbstractOrderServiceAdds 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.- Specified by:
addAllTotalTaxValuesin interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- target ordertaxValues- tax values to add
-
removeGlobalDiscountValue
public void removeGlobalDiscountValue(O order, DiscountValue discountValue)
Description copied from interface:AbstractOrderServiceRemoves 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.- Specified by:
removeGlobalDiscountValuein interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- target orderdiscountValue- discount to remove
-
removeTotalTaxValue
public void removeTotalTaxValue(O order, TaxValue taxValue)
Description copied from interface:AbstractOrderServiceRemoves 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.- Specified by:
removeTotalTaxValuein interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>- Parameters:
order- target order
-
getEntryTypeCode
protected java.lang.String getEntryTypeCode(AbstractOrderModel order)
-
getCollidingEntry
protected AbstractOrderEntryModel getCollidingEntry(int requested, O order)
-
setOrderDao
public void setOrderDao(OrderDao orderDao)
-
setAbstractOrderEntryTypeService
public void setAbstractOrderEntryTypeService(AbstractOrderEntryTypeService abstractOrderEntryTypeService)
-
setSaveAbstractOrderStrategy
public void setSaveAbstractOrderStrategy(SaveAbstractOrderStrategy<O> saveAbstractOrderStrategy)
-
setCloneAbstractOrderStrategy
public void setCloneAbstractOrderStrategy(CloneAbstractOrderStrategy cloneAbstractOrderStrategy)
-
setAbstractOrderEntryService
public void setAbstractOrderEntryService(AbstractOrderEntryService<E> abstractOrderEntryService)
-
getCloneAbstractOrderStrategy
protected CloneAbstractOrderStrategy getCloneAbstractOrderStrategy()
-
getAbstractOrderEntryTypeService
protected AbstractOrderEntryTypeService getAbstractOrderEntryTypeService()
-
getSaveAbstractOrderStrategy
protected SaveAbstractOrderStrategy<O> getSaveAbstractOrderStrategy()
-
getAbstractOrderEntryService
protected AbstractOrderEntryService<E> getAbstractOrderEntryService()
-
getOrderDao
protected OrderDao getOrderDao()
-
getGlobalDiscountValue
public DiscountValue getGlobalDiscountValue(O order, DiscountValue discountValue)
Description copied from interface:AbstractOrderServiceSearches 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.- Specified by:
getGlobalDiscountValuein interfaceAbstractOrderService<O extends AbstractOrderModel,E extends AbstractOrderEntryModel>
-
-