public abstract class Voucher extends GeneratedVoucher
| Modifier and Type | Class and Description |
|---|---|
protected class |
Voucher.InvalidVoucherKeyException |
GenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException| Modifier and Type | Field and Description |
|---|---|
protected static int |
CODELENGTH |
protected static String |
DIVIDER |
protected static int |
LENGTH_CODE |
DEFAULT_INITIAL_ATTRIBUTES, DESCRIPTION, FREESHIPPING, INVALIDATIONS, INVALIDATIONSHANDLER, RESTRICTIONS, RESTRICTIONSHANDLER, VALUESTRINGEXTERNAL_KEY, GLOBAL, VALUE_END, VALUE_STARTABSOLUTE, CODE, CURRENCY, DISCOUNTSTRING, NAME, ORDERDISCOUNTRELATION_MARKMODIFIED, ORDERDISCOUNTRELATION_SRC_ORDERED, ORDERDISCOUNTRELATION_TGT_ORDERED, ORDERS, PRIORITY, VALUELANGUAGE_FALLBACK_ENABLED_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEimpl, tenant| Constructor and Description |
|---|
Voucher() |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
checkVoucherCode(String aVoucherCode)
Returns true if the specified voucher code is valid for this voucher.
|
protected void |
createAndStoreKey(SessionContext ctx,
Discount item) |
protected Item |
createItem(SessionContext ctx,
ComposedType type,
Item.ItemAttributeMap allAttributes)
Has to be implemented for each concrete subtype of item.
|
VoucherInvalidation |
createVoucherInvalidation(String aVoucherCode,
Order anOrder) |
String |
generateVoucherCode() |
VoucherEntrySet |
getApplicableEntries(AbstractOrder anOrder)
Returns all positions or parts of positions of the specified abstract order that are eligible for this voucher.
|
protected VoucherValue |
getApplicableValue(AbstractOrder anOrder)
Returns a VoucherValue object representing the partial value of the total of the specified abstract order
that is eligible for this voucher.
|
VoucherValue |
getAppliedValue(AbstractOrder anOrder)
Returns a VoucherValue object representing the discount value of this voucher.
|
protected ComposedType |
getComposedType(Class aClass) |
DiscountValue |
getDiscountValue(AbstractOrder anOrder)
Calculates a
value which should be applied to the given order during (re)calculation. |
protected VoucherInvalidation |
getInvalidation(String aVoucherCode,
Order anOrder)
Returns a voucher invalidation object if the specified voucher code was used in the specified order or
null else.
|
protected Collection<VoucherInvalidation> |
getInvalidations(String aVoucherCode)
Returns all voucher invalidations representing the usage of the specified voucher code.
|
protected Collection<VoucherInvalidation> |
getInvalidations(String aVoucherCode,
User anUser)
Returns all voucher invalidations representing the usage of the specified voucher code by the specified user.
|
protected abstract int |
getNextVoucherNumber(SessionContext ctx) |
String |
getValueString(SessionContext ctx)
Convenience method.
|
List<Restriction> |
getViolatedRestrictions(AbstractOrder anOrder)
Returns all restrictions that are not fulfilled by the specified abstract order.
|
List<Restriction> |
getViolatedRestrictions(Product aProduct)
Returns all restrictions that are not fulfilled by the specified product.
|
List<String> |
getViolationMessages(AbstractOrder anOrder) |
List<String> |
getViolationMessages(Product aProduct) |
protected int |
getVoucherNumber(String voucherCode) |
VoucherValue |
getVoucherValue(AbstractOrder anOrder) |
protected static String |
insertDividers(String voucherCode) |
boolean |
isApplicable(AbstractOrder anOrder)
Returns true if the specified abstract order is eligible for this voucher.
|
boolean |
isApplicable(Product aProduct)
Returns true if the specified product is eligible for this voucher.
|
boolean |
isReservable(String aVoucherCode,
AbstractOrder abstractOrder) |
abstract boolean |
isReservable(String aVoucherCode,
User user) |
boolean |
redeem(String aVoucherCode,
Cart aCart) |
VoucherInvalidation |
redeem(String aVoucherCode,
Order anOrder) |
void |
release(String aVoucherCode,
Cart aCart) |
void |
release(String aVoucherCode,
Order anOrder) |
void |
remove(SessionContext ctx)
Removes this item.
|
protected static String |
removeDividers(String voucherCode) |
protected void |
removeInvalidations(SessionContext ctx)
Upon voucher removal this method deletes all
VoucherInvalidation items which belong to this voucher. |
VoucherInvalidation |
reserve(String aVoucherCode,
Order anOrder) |
protected String |
threeByteSig(String sigText) |
addToInvalidations, addToInvalidations, addToRestrictions, addToRestrictions, getAllDescription, getAllDescription, getDefaultAttributeModes, getDescription, getDescription, getInvalidations, getInvalidations, getRestrictions, getRestrictions, getValueString, isFreeShipping, isFreeShipping, isFreeShippingAsPrimitive, isFreeShippingAsPrimitive, removeFromInvalidations, removeFromInvalidations, removeFromRestrictions, removeFromRestrictions, setAllDescription, setAllDescription, setDescription, setDescription, setFreeShipping, setFreeShipping, setFreeShipping, setFreeShipping, setInvalidations, setInvalidations, setRestrictions, setRestrictionsaddOrder, getAllNames, getDiscountstring, getDiscountString, getPriority, getValue, isAbsolute, notifyOrderCalculated, notifyOrderRemoval, removeOrder, setAllNames, setCodeaddToOrders, addToOrders, getAllName, getAllName, getCode, getCode, getCurrency, getCurrency, getDiscountString, getName, getName, getOrders, getOrders, getOrdersCount, getOrdersCount, getPriority, getPriorityAsPrimitive, getPriorityAsPrimitive, getValue, getValueAsPrimitive, getValueAsPrimitive, isAbsolute, isAbsoluteAsPrimitive, isAbsoluteAsPrimitive, isGlobal, isGlobal, isGlobalAsPrimitive, isGlobalAsPrimitive, removeFromOrders, removeFromOrders, setAllName, setAllName, setCode, setCurrency, setCurrency, setGlobal, setGlobal, setGlobal, setGlobal, setName, setName, setOrders, setOrders, setPriority, setPriority, setPriority, setPriority, setValue, setValue, setValue, setValuegetInitialProperties, getNonInitialAttributesgetAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertycreateNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyaddLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, readResolve, refreshRemote, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setTransientObject, setUseTA, toString, useTA, writeReplacegetImplementation, setTenantprotected static final int CODELENGTH
protected static final int LENGTH_CODE
protected static final String DIVIDER
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
ItemComposedType.newInstance(Map).
In case this method uses any of the attribute values during creation it is required to override
Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
Sn example:
public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
// here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
super.getNonInitialAttributes( ctx, allAttributes );
// remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
createItem in class Discountctx - the current session context which this item is created withintype - the actual item type ( since subtypes may not provide a own jalo class this may be different from the
type which this method was implemented for )JaloBusinessException - indicates an error during creation - any changes will be rollbackedpublic void remove(SessionContext ctx) throws ConsistencyCheckException
Item
This method is using the following attributes of the given SessionContext:
| CacheUsage | Language | StagingMethod | ||
|---|---|---|---|---|
| n/a (this is a setter method) | no, language doesn't matter for removal | yes if called on a StageableItem, no otherwise |
remove in class Itemctx - A SessionContext objectConsistencyCheckException - if this item could not be removed for some reasonprotected void removeInvalidations(SessionContext ctx)
VoucherInvalidation items which belong to this voucher.ctx - protected void createAndStoreKey(SessionContext ctx, Discount item)
public VoucherInvalidation createVoucherInvalidation(String aVoucherCode, Order anOrder)
public abstract boolean checkVoucherCode(String aVoucherCode)
aVoucherCode - the voucher code to check validity of.public VoucherEntrySet getApplicableEntries(AbstractOrder anOrder)
anOrder - the abstract order to get eligible positions of.protected VoucherValue getApplicableValue(AbstractOrder anOrder)
anOrder - the abstract order to get applicable value of.public VoucherValue getAppliedValue(AbstractOrder anOrder)
anOrder - the abstract order to get discount value of.protected ComposedType getComposedType(Class aClass)
public DiscountValue getDiscountValue(AbstractOrder anOrder)
Discountvalue which should be applied to the given order during (re)calculation.getDiscountValue in class DiscountanOrder - the order which is currently being calculatedprotected VoucherInvalidation getInvalidation(String aVoucherCode, Order anOrder)
aVoucherCode - the voucher code to check.anOrder - the order to check.protected Collection<VoucherInvalidation> getInvalidations(String aVoucherCode)
aVoucherCode - the voucher code to checkprotected Collection<VoucherInvalidation> getInvalidations(String aVoucherCode, User anUser)
aVoucherCode - the voucher code to checkanUser - the user to checkpublic String getValueString(SessionContext ctx)
getValueString in class GeneratedVoucherctx - the context of the actual sessionpublic List<Restriction> getViolatedRestrictions(AbstractOrder anOrder)
anOrder - the abstract order to return violated restrictions for.public List<Restriction> getViolatedRestrictions(Product aProduct)
aProduct - the product to return violated restrictions for.public List<String> getViolationMessages(AbstractOrder anOrder)
public VoucherValue getVoucherValue(AbstractOrder anOrder)
public boolean isApplicable(AbstractOrder anOrder)
anOrder - the abstract order to check whether it is eligible for this voucher.public boolean isApplicable(Product aProduct)
aProduct - the product to check whether it is eligible for this voucher.public boolean isReservable(String aVoucherCode, AbstractOrder abstractOrder)
public boolean redeem(String aVoucherCode, Cart aCart) throws JaloPriceFactoryException
JaloPriceFactoryExceptionpublic VoucherInvalidation redeem(String aVoucherCode, Order anOrder)
public void release(String aVoucherCode, Order anOrder) throws ConsistencyCheckException
ConsistencyCheckExceptionpublic void release(String aVoucherCode, Cart aCart) throws JaloPriceFactoryException
JaloPriceFactoryExceptionpublic VoucherInvalidation reserve(String aVoucherCode, Order anOrder)
public String generateVoucherCode() throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionprotected abstract int getNextVoucherNumber(SessionContext ctx)
protected int getVoucherNumber(String voucherCode) throws Voucher.InvalidVoucherKeyException
protected String threeByteSig(String sigText) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionCopyright © 2017 SAP SE. All Rights Reserved.