com.elasticpath.domain.catalog.impl
Class ProductSkuImpl

java.lang.Object
  extended by com.elasticpath.domain.impl.AbstractEpDomainImpl
      extended by com.elasticpath.domain.impl.AbstractPersistenceImpl
          extended by com.elasticpath.domain.impl.AbstractEntityImpl
              extended by com.elasticpath.domain.catalog.impl.ProductSkuImpl
All Implemented Interfaces:
ProductSku, Entity, EpDomain, Persistence, java.io.Serializable

public class ProductSkuImpl
extends AbstractEntityImpl
implements ProductSku

ProductSku represents a variation of a merchandise product in Elastic Path. A ProductSku corresponds to a single Product NOTE: The way prices are implemented and retrieved may need some refactoring as requirements are further developed.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Constructor Summary
ProductSkuImpl()
          Default constructor.
 
Method Summary
 void addPrice(Price price)
          Convenience method for setting the price.
 void clearPromotionPrice()
          Removes computed promotion prices.
 boolean equals(java.lang.Object obj)
          Returns true if this sku equals to the given object.
 AttributeValueGroup getAttributeValueGroup()
          Get the attribute value group.
 DigitalAsset getDigitalAsset()
          Gets the digital asset belong to this product SKU.
 java.util.Date getEndDate()
          Get the end date.
 java.lang.String getGuid()
          Return the guid.
 java.lang.String getImage()
          Get the sku default image.
 Inventory getInventory()
          Get the Inventory for this product sku.
 java.util.Set getOptionValueCodes()
          Get the option value codes for this SKU.
 java.util.Map getOptionValueMap()
          Gets the available configuration option values for this SKU.
 java.util.Collection getOptionValues()
          Get the available values for this SKU option.
 Price getPrice(java.util.Currency currency)
          Get the price of this product sku in the specified currency.
 Price getPriceWithoutFallback(java.util.Currency currency)
          Get the price of this product sku in the specified currency.
 Product getProduct()
          Get the parent product corresponding to this SKU.
 java.util.Map getProductSkuPrices()
          Get the product-price associations belong to this product SKU.
 java.lang.String getSkuCode()
          Get the product system name.
 SkuOptionValue getSkuOptionValue(SkuOption skuOption)
          Returns the value of the given SkuOption.
 ProductSkuSpec getSpec()
          Returns the ProductSkuSpec instance -- the product sku specification.
 java.util.Date getStartDate()
          Get the start date that this product will become available to customers.
 int hashCode()
          Hash code.
 boolean hasSufficientInventory(int quantity)
          Returns true if there is sufficient stock of this SKU to sell the specified quantity of items.
 boolean isAvailable()
          Returns true if the product is available to be purchased.
 boolean isShippable()
          True if this SKU is shippable (i.e.
 boolean isVisibleWhenOutOfStock()
          True if this SKU is visible in the when out of stock.
 void setAttributeValueGroup(AttributeValueGroup attributeValueGroup)
          Set the attribute value group.
 void setDefaultValues()
          Set default values for those fields need default values.
 void setDigitalAsset(DigitalAsset digitalAsset)
          Sets the digital asset.
 void setEndDate(java.util.Date endDate)
          Set the end date.
 void setGuid(java.lang.String guid)
          Set the guid.
 void setImage(java.lang.String image)
          Set the sku default image.
 void setInventory(Inventory inventory)
          Set the Inventory for this product sku.
 void setOptionValueMap(java.util.Map optionValueMap)
          Sets the available configuration option values for this SKU.
 void setProduct(Product newProduct)
          Set the parent product of this SKU.
 void setProductOneWay(Product product)
          Set the parent product of this SKU.
 void setProductSkuPrices(java.util.Map productSkuPrices)
          Set the product-price assocations of this product SKU.
 void setShippable(boolean shippable)
          Sets if this SKU is shippable (i.e.
 void setSkuCode(java.lang.String skuCode)
          Set the SKU for this product variation.
 void setSkuOptionValue(SkuOption skuOption, java.lang.String valueCode)
          Sets the sku option value to the one corresponding given value code.
 void setSpec(ProductSkuSpec spec)
          Sets the ProductSkuSpec instance -- the product sku specification.
 void setStartDate(java.util.Date startDate)
          Set the start date that this product will become valid.
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEntityImpl
convertAttributeGroupAttributes
 
Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl
executeBeforePersistAction, getUidPk, isPersistent, setUidPk
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

ProductSkuImpl

public ProductSkuImpl()
Default constructor.

Method Detail

addPrice

public void addPrice(Price price)
Convenience method for setting the price. If the price exists, its amount is updated. Otherwise the price is added.

Specified by:
addPrice in interface ProductSku
Parameters:
price - the price to be added.

clearPromotionPrice

public void clearPromotionPrice()
Removes computed promotion prices.

Specified by:
clearPromotionPrice in interface ProductSku

equals

public boolean equals(java.lang.Object obj)
Returns true if this sku equals to the given object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the given object
Returns:
true if this sku equals to the given object

getAttributeValueGroup

public AttributeValueGroup getAttributeValueGroup()
Get the attribute value group.

Specified by:
getAttributeValueGroup in interface ProductSku
Returns:
the domain model's AttributeValueGroup

getDigitalAsset

public DigitalAsset getDigitalAsset()
Gets the digital asset belong to this product SKU.

Specified by:
getDigitalAsset in interface ProductSku
Returns:
the digital asset belong to this product SKU

getEndDate

public java.util.Date getEndDate()
Get the end date. After the end date, the product will change to unavailable to customers.

Specified by:
getEndDate in interface ProductSku
Returns:
the end date

getGuid

public java.lang.String getGuid()
Return the guid.

Specified by:
getGuid in interface Entity
Overrides:
getGuid in class AbstractEntityImpl
Returns:
the guid.

getImage

public java.lang.String getImage()
Get the sku default image. Returns the product default image if no sku image exists

Specified by:
getImage in interface ProductSku
Returns:
the sku default image

getInventory

public Inventory getInventory()
Get the Inventory for this product sku.

Specified by:
getInventory in interface ProductSku
Returns:
the Inventory

getOptionValueCodes

public java.util.Set getOptionValueCodes()
Get the option value codes for this SKU.

Specified by:
getOptionValueCodes in interface ProductSku
Returns:
a set of strings of the option value codes

getOptionValueMap

public java.util.Map getOptionValueMap()
Gets the available configuration option values for this SKU.

Specified by:
getOptionValueMap in interface ProductSku
Returns:
a map of SkuOptionValues

getOptionValues

public java.util.Collection getOptionValues()
Get the available values for this SKU option.

Specified by:
getOptionValues in interface ProductSku
Returns:
a set of SkuOptionValues

getPrice

public Price getPrice(java.util.Currency currency)
Get the price of this product sku in the specified currency.

Specified by:
getPrice in interface ProductSku
Parameters:
currency - the Currency of the price to be returned
Returns:
a Price object representing the price in the specified currency. If no price is found, the parent product's price is returned. returns null if no price was found in the specified currency.

getPriceWithoutFallback

public Price getPriceWithoutFallback(java.util.Currency currency)
Get the price of this product sku in the specified currency.

Specified by:
getPriceWithoutFallback in interface ProductSku
Parameters:
currency - the Currency of the price to be returned
Returns:
a Price object representing the price in the specified currency. If no price is found, return null.

getProduct

public Product getProduct()
Get the parent product corresponding to this SKU.

Specified by:
getProduct in interface ProductSku
Returns:
the parent Product

getProductSkuPrices

public java.util.Map getProductSkuPrices()
Get the product-price associations belong to this product SKU.

Specified by:
getProductSkuPrices in interface ProductSku
Returns:
the set of prices corresponding to this product SKU

getSkuCode

public java.lang.String getSkuCode()
Get the product system name.

Specified by:
getSkuCode in interface ProductSku
Returns:
the product SKU

getSkuOptionValue

public SkuOptionValue getSkuOptionValue(SkuOption skuOption)
Returns the value of the given SkuOption. Returns null if the value is not defined.

Specified by:
getSkuOptionValue in interface ProductSku
Parameters:
skuOption - the sku option
Returns:
the value of the given SkuOption. null if the value is not defined.

getSpec

public ProductSkuSpec getSpec()
Returns the ProductSkuSpec instance -- the product sku specification.

Specified by:
getSpec in interface ProductSku
Returns:
the ProductSkuSpec instance -- the product sku specification.

getStartDate

public java.util.Date getStartDate()
Get the start date that this product will become available to customers.

Specified by:
getStartDate in interface ProductSku
Returns:
the start date

hashCode

public int hashCode()
Hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

hasSufficientInventory

public boolean hasSufficientInventory(int quantity)
Returns true if there is sufficient stock of this SKU to sell the specified quantity of items.

Specified by:
hasSufficientInventory in interface ProductSku
Parameters:
quantity - the quantity of items to check for availability
Returns:
true if quantity items can be sold

isAvailable

public boolean isAvailable()
Returns true if the product is available to be purchased. Currently, this means that the current date is within the start and end dates for this product.

Specified by:
isAvailable in interface ProductSku
Returns:
true if the product is available at today's date.

isShippable

public boolean isShippable()
True if this SKU is shippable (i.e. is a physical good which requires shipping).

Specified by:
isShippable in interface ProductSku
Returns:
true if this SKU is shippable

isVisibleWhenOutOfStock

public boolean isVisibleWhenOutOfStock()
True if this SKU is visible in the when out of stock.

Specified by:
isVisibleWhenOutOfStock in interface ProductSku
Returns:
true if this SKU is visible in the when out of stock

setAttributeValueGroup

public void setAttributeValueGroup(AttributeValueGroup attributeValueGroup)
Set the attribute value group.

Specified by:
setAttributeValueGroup in interface ProductSku
Parameters:
attributeValueGroup - the AttributeValueGroup

setDefaultValues

public void setDefaultValues()
Set default values for those fields need default values.

Specified by:
setDefaultValues in interface Persistence
Overrides:
setDefaultValues in class AbstractEntityImpl

setDigitalAsset

public void setDigitalAsset(DigitalAsset digitalAsset)
Sets the digital asset.

Specified by:
setDigitalAsset in interface ProductSku
Parameters:
digitalAsset - the digital asset

setEndDate

public void setEndDate(java.util.Date endDate)
Set the end date.

Specified by:
setEndDate in interface ProductSku
Parameters:
endDate - the end date

setGuid

public void setGuid(java.lang.String guid)
Set the guid.

Specified by:
setGuid in interface Entity
Overrides:
setGuid in class AbstractEntityImpl
Parameters:
guid - the guid to set.

setImage

public void setImage(java.lang.String image)
Set the sku default image.

Specified by:
setImage in interface ProductSku
Parameters:
image - the sku default image

setInventory

public void setInventory(Inventory inventory)
Set the Inventory for this product sku.

Specified by:
setInventory in interface ProductSku
Parameters:
inventory - the Inventory

setOptionValueMap

public void setOptionValueMap(java.util.Map optionValueMap)
Sets the available configuration option values for this SKU.

Specified by:
setOptionValueMap in interface ProductSku
Parameters:
optionValueMap - the map of SkuOptionValues.

setProduct

public void setProduct(Product newProduct)
Set the parent product of this SKU.

Specified by:
setProduct in interface ProductSku
Parameters:
newProduct - the parent product

setProductOneWay

public void setProductOneWay(Product product)
Set the parent product of this SKU. Notice: this method doesn't maintains the bidirectional relationships between the given product and the sku. It won't add this sku to the given product's sku collectin. This method can be used in some special circumstance to get better performance, like import. Generally, you shouldn't use the given product any more after this method get called because its sku collection is not consistent any more.

Specified by:
setProductOneWay in interface ProductSku
Parameters:
product - the parent product

setProductSkuPrices

public void setProductSkuPrices(java.util.Map productSkuPrices)
Set the product-price assocations of this product SKU.

Parameters:
productSkuPrices - the product SKU prices to set

setShippable

public void setShippable(boolean shippable)
Sets if this SKU is shippable (i.e. is a physical good which requires shipping).

Specified by:
setShippable in interface ProductSku
Parameters:
shippable - the shippable flag for the SKU

setSkuCode

public void setSkuCode(java.lang.String skuCode)
Set the SKU for this product variation.

Specified by:
setSkuCode in interface ProductSku
Parameters:
skuCode - the SKU

setSkuOptionValue

public void setSkuOptionValue(SkuOption skuOption,
                              java.lang.String valueCode)
                       throws EpInvalidValueBindException
Sets the sku option value to the one corresponding given value code.

Specified by:
setSkuOptionValue in interface ProductSku
Parameters:
skuOption - the sku option
valueCode - the sku option value code
Throws:
EpInvalidValueBindException - in case the given value code is not defined in the given SkuOption

setSpec

public void setSpec(ProductSkuSpec spec)
Sets the ProductSkuSpec instance -- the product sku specification.

Specified by:
setSpec in interface ProductSku
Parameters:
spec - the product sku specification.

setStartDate

public void setStartDate(java.util.Date startDate)
Set the start date that this product will become valid.

Specified by:
setStartDate in interface ProductSku
Parameters:
startDate - the start date