org.broadleafcommerce.core.catalog.domain
Class SkuImpl

java.lang.Object
  extended by org.broadleafcommerce.core.catalog.domain.SkuImpl
All Implemented Interfaces:
Serializable, Sku

@Entity
public class SkuImpl
extends Object
implements Sku

The Class SkuImpl is the default implementation of Sku. A SKU is a specific item that can be sold including any specific attributes of the item such as color or size.

If you want to add fields specific to your implementation of BroadLeafCommerce you should extend this class and add your fields. If you need to make significant changes to the SkuImpl then you should implement your own version of Sku.

This implementation uses a Hibernate implementation of JPA configured through annotations. The Entity references the following tables: BLC_SKU, BLC_SKU_IMAGE

Author:
btaylor
See Also:
Sku}, Serialized Form

Field Summary
protected  Date activeEndDate
          The active end date.
protected  Date activeStartDate
          The active start date.
protected  Character available
          The available.
protected  Product defaultProduct
          This will be non-null if and only if this Sku is the default Sku for a Product
protected  String description
          The description.
protected  Dimension dimension
          The product dimensions
protected  Character discountable
          The discountable.
protected  DynamicSkuPrices dynamicPrices
           
protected  List<FulfillmentOption> excludedFulfillmentOptions
           
protected  List<SkuFee> fees
           
protected  Map<FulfillmentOption,BigDecimal> fulfillmentFlatRates
           
protected  Long id
          The id.
protected  Boolean isMachineSortable
           
protected  String longDescription
          The long description.
protected  String name
          The name.
protected  Product product
          This relationship will be non-null if and only if this Sku is contained in the list of additional Skus for a Product (for Skus based on ProductOptions)
protected  List<ProductOptionValue> productOptionValues
           
protected  BigDecimal retailPrice
          The retail price.
protected  BigDecimal salePrice
          The sale price.
protected  List<SkuAttribute> skuAttributes
           
protected  Map<String,Media> skuMedia
          The sku media.
protected  Character taxable
          The taxable.
protected  Weight weight
          The product weight
 
Constructor Summary
SkuImpl()
           
 
Method Summary
 boolean equals(Object obj)
           
 Date getActiveEndDate()
          Returns the the last date that the Sku should be available for sale.
 Date getActiveStartDate()
          Returns the first date that the Sku should be available for sale.
 Boolean getAvailable()
          Convenience that passes through to isAvailable
 Product getDefaultProduct()
          This will be a value if and only if this Sku is the defaultSku of a Product (and thus has a @OneToOne relationship with a Product).
 String getDescription()
          Returns the brief description of the Sku.
 Dimension getDimension()
          Get the dimensions for this Sku
 Boolean getDiscountable()
           
 List<FulfillmentOption> getExcludedFulfillmentOptions()
          Gets the FulfillmentOptions that this Sku should be excluded from.
 List<SkuFee> getFees()
          Gets all the extra fees for this particular Sku.
 Map<FulfillmentOption,BigDecimal> getFulfillmentFlatRates()
          Gets the flat rate for fulfilling this Sku for a particular FulfillmentOption.
 Long getId()
          Returns the id of this sku
 Money getListPrice()
          Returns the List Price of the Sku.
 String getLongDescription()
          Returns the long description of the sku.
 Map<String,SkuAttribute> getMappedSkuAttributes()
           
 String getName()
          Returns the name of the Sku.
 Product getProduct()
          This will return the correct Product association that is being used on the Sku.
 Money getProductOptionValueAdjustments()
          This is the sum total of the priceAdjustments from the associated ProductOptionValues
 List<ProductOptionValue> getProductOptionValues()
          Gets the ProductOptionValues used to map to this Sku.
 Money getRetailPrice()
          Returns the Retail Price of the Sku.
 Money getSalePrice()
          Returns the Sale Price of the Sku.
 SkuAttribute getSkuAttributeByName(String name)
          Convenience method to return a given sku attribute by its name
 List<SkuAttribute> getSkuAttributes()
          Denormalized set of key-value pairs to attach to a Sku.
 Map<String,Media> getSkuMedia()
          Returns a map of key/value pairs where the key is a string for the name of a media object and the value is a media object.
 Boolean getTaxable()
          Convenience that passes through to isTaxable
 Weight getWeight()
          Gets the embedded Weight for this Sku
 int hashCode()
           
 boolean isActive()
          Returns a boolean indicating whether this sku is active.
 boolean isActive(Product product, Category category)
          Returns whether or not this Sku, the given Product and the given Category are all active
 Boolean isAvailable()
          Returns whether the Sku is available.
 Boolean isDiscountable()
          Returns whether the Sku qualifies for discounts or not.
 Boolean isMachineSortable()
          Whether this Sku can be sorted by a machine
 boolean isOnSale()
          A product is on sale provided the sale price is not null, non-zero, and less than the retail price
 Boolean isTaxable()
          Returns whether the Sku qualifies for taxes or not.
 void setActiveEndDate(Date activeEndDate)
          Sets the the last date that the Sku should be available for sale.
 void setActiveStartDate(Date activeStartDate)
          Sets the the first date that the Sku should be available for sale.
 void setAvailable(Boolean available)
          Sets the whether the Sku is available.
 void setDefaultProduct(Product defaultProduct)
          The relationship for a Product's default Sku (and thus a Sku's default Product) is actually maintained on the Product entity as a foreign key to Sku.
 void setDescription(String description)
          Sets the brief description of the Sku.
 void setDimension(Dimension dimension)
          Sets the embedded Dimension for this Sku
 void setDiscountable(Boolean discountable)
          Sets the whether the Sku qualifies for discounts or not.
 void setExcludedFulfillmentOptions(List<FulfillmentOption> excludedFulfillmentOptions)
          Sets the FulfillmentOptions that this Sku should be excluded from being apart of
 void setFees(List<SkuFee> fees)
          Sets the extra fees for this particular Sku
 void setFulfillmentFlatRates(Map<FulfillmentOption,BigDecimal> fulfillmentFlatRates)
          Sets the flat rates for fulfilling this Sku for a particular FulfillmentOption.
 void setId(Long id)
          Sets the id of this sku
 void setListPrice(Money listPrice)
          Sets the the List Price of the Sku.
 void setLongDescription(String longDescription)
          Sets the long description of the sku.
 void setMachineSortable(Boolean isMachineSortable)
          Sets whether or not this Sku can be sorted by a machine
 void setName(String name)
          Sets the the name of the Sku.
 void setProduct(Product product)
          Associates a Sku to a given Product.
 void setProductOptionValues(List<ProductOptionValue> productOptionValues)
          Sets the ProductOptionValues that should be mapped to this Sku
 void setRetailPrice(Money retailPrice)
          Sets the retail price for the Sku.
 void setSalePrice(Money salePrice)
          Sets the the Sale Price of the Sku.
 void setSkuAttributes(List<SkuAttribute> skuAttributes)
          Sets the denormalized set of key-value pairs on a Sku
 void setSkuMedia(Map<String,Media> skuMedia)
          Sets a map of key/value pairs where the key is a string for the name of a media object and the value is an object of type Media.
 void setTaxable(Boolean taxable)
          Sets the whether the Sku qualifies for taxes or not.
 void setWeight(Weight weight)
          Sets the embedded Weight for this Sku
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected Long id
The id.


salePrice

protected BigDecimal salePrice
The sale price.


retailPrice

protected BigDecimal retailPrice
The retail price.


name

protected String name
The name.


description

protected String description
The description.


longDescription

protected String longDescription
The long description.


taxable

protected Character taxable
The taxable.


discountable

protected Character discountable
The discountable.


available

protected Character available
The available.


activeStartDate

protected Date activeStartDate
The active start date.


activeEndDate

protected Date activeEndDate
The active end date.


dimension

protected Dimension dimension
The product dimensions


weight

protected Weight weight
The product weight


dynamicPrices

protected DynamicSkuPrices dynamicPrices

isMachineSortable

protected Boolean isMachineSortable

skuMedia

protected Map<String,Media> skuMedia
The sku media.


defaultProduct

protected Product defaultProduct
This will be non-null if and only if this Sku is the default Sku for a Product


product

protected Product product
This relationship will be non-null if and only if this Sku is contained in the list of additional Skus for a Product (for Skus based on ProductOptions)


skuAttributes

protected List<SkuAttribute> skuAttributes

productOptionValues

protected List<ProductOptionValue> productOptionValues

fees

protected List<SkuFee> fees

fulfillmentFlatRates

protected Map<FulfillmentOption,BigDecimal> fulfillmentFlatRates

excludedFulfillmentOptions

protected List<FulfillmentOption> excludedFulfillmentOptions
Constructor Detail

SkuImpl

public SkuImpl()
Method Detail

getId

public Long getId()
Description copied from interface: Sku
Returns the id of this sku

Specified by:
getId in interface Sku

setId

public void setId(Long id)
Description copied from interface: Sku
Sets the id of this sku

Specified by:
setId in interface Sku

isOnSale

public boolean isOnSale()
Description copied from interface: Sku
A product is on sale provided the sale price is not null, non-zero, and less than the retail price

Specified by:
isOnSale in interface Sku
Returns:
whether or not the product is on sale

getProductOptionValueAdjustments

public Money getProductOptionValueAdjustments()
Description copied from interface: Sku
This is the sum total of the priceAdjustments from the associated ProductOptionValues

Specified by:
getProductOptionValueAdjustments in interface Sku
Returns:
null if there are no ProductOptionValues associated with this Sku or all of their priceAdjustments are null. Otherwise this will be the sum total of those price adjustments
See Also:
ProductOptionValue}

getSalePrice

public Money getSalePrice()
Description copied from interface: Sku
Returns the Sale Price of the Sku. The Sale Price is the standard price the vendor sells this item for. If SkuPricingConsiderationContext is set, this uses the DynamicSkuPricingService to calculate what this should actually be rather than use the property itself

Specified by:
getSalePrice in interface Sku
See Also:
SkuPricingConsiderationContext, DynamicSkuPricingService

setSalePrice

public void setSalePrice(Money salePrice)
Description copied from interface: Sku
Sets the the Sale Price of the Sku. The Sale Price is the standard price the vendor sells this item for. This price will automatically be overridden if your system is utilizing the DynamicSkuPricingService.

Specified by:
setSalePrice in interface Sku

getRetailPrice

public Money getRetailPrice()
Description copied from interface: Sku
Returns the Retail Price of the Sku. The Retail Price is the MSRP of the sku. If SkuPricingConsiderationContext is set, this uses the DynamicSkuPricingService to calculate what this should actually be rather than use the property itself

Specified by:
getRetailPrice in interface Sku
See Also:
SkuPricingConsiderationContext, DynamicSkuPricingService

setRetailPrice

public void setRetailPrice(Money retailPrice)
Description copied from interface: Sku
Sets the retail price for the Sku. This price will automatically be overridden if your system is utilizing the DynamicSkuPricingService.

Specified by:
setRetailPrice in interface Sku

getListPrice

public Money getListPrice()
Description copied from interface: Sku
Returns the List Price of the Sku. The List Price is the MSRP of the sku.

Specified by:
getListPrice in interface Sku

setListPrice

public void setListPrice(Money listPrice)
Description copied from interface: Sku
Sets the the List Price of the Sku. The List Price is the MSRP of the sku.

Specified by:
setListPrice in interface Sku

getName

public String getName()
Description copied from interface: Sku
Returns the name of the Sku. The name is a label used to show when displaying the sku.

Specified by:
getName in interface Sku

setName

public void setName(String name)
Description copied from interface: Sku
Sets the the name of the Sku. The name is a label used to show when displaying the sku.

Specified by:
setName in interface Sku

getDescription

public String getDescription()
Description copied from interface: Sku
Returns the brief description of the Sku.

Specified by:
getDescription in interface Sku

setDescription

public void setDescription(String description)
Description copied from interface: Sku
Sets the brief description of the Sku.

Specified by:
setDescription in interface Sku

getLongDescription

public String getLongDescription()
Description copied from interface: Sku
Returns the long description of the sku.

Specified by:
getLongDescription in interface Sku

setLongDescription

public void setLongDescription(String longDescription)
Description copied from interface: Sku
Sets the long description of the sku.

Specified by:
setLongDescription in interface Sku

isTaxable

public Boolean isTaxable()
Description copied from interface: Sku
Returns whether the Sku qualifies for taxes or not. This field is used by the pricing engine to calculate taxes.

Specified by:
isTaxable in interface Sku

getTaxable

public Boolean getTaxable()
Description copied from interface: Sku
Convenience that passes through to isTaxable

Specified by:
getTaxable in interface Sku

setTaxable

public void setTaxable(Boolean taxable)
Description copied from interface: Sku
Sets the whether the Sku qualifies for taxes or not. This field is used by the pricing engine to calculate taxes.

Specified by:
setTaxable in interface Sku

isDiscountable

public Boolean isDiscountable()
Description copied from interface: Sku
Returns whether the Sku qualifies for discounts or not. This field is used by the pricing engine to apply offers.

Specified by:
isDiscountable in interface Sku

getDiscountable

public Boolean getDiscountable()

setDiscountable

public void setDiscountable(Boolean discountable)
Description copied from interface: Sku
Sets the whether the Sku qualifies for discounts or not. This field is used by the pricing engine to apply offers.

Specified by:
setDiscountable in interface Sku

isAvailable

public Boolean isAvailable()
Description copied from interface: Sku
Returns whether the Sku is available.

Specified by:
isAvailable in interface Sku

getAvailable

public Boolean getAvailable()
Description copied from interface: Sku
Convenience that passes through to isAvailable

Specified by:
getAvailable in interface Sku

setAvailable

public void setAvailable(Boolean available)
Description copied from interface: Sku
Sets the whether the Sku is available.

Specified by:
setAvailable in interface Sku

getActiveStartDate

public Date getActiveStartDate()
Description copied from interface: Sku
Returns the first date that the Sku should be available for sale. This field is used to determine whether a user can add the sku to their cart.

Specified by:
getActiveStartDate in interface Sku

setActiveStartDate

public void setActiveStartDate(Date activeStartDate)
Description copied from interface: Sku
Sets the the first date that the Sku should be available for sale. This field is used to determine whether a user can add the sku to their cart.

Specified by:
setActiveStartDate in interface Sku

getActiveEndDate

public Date getActiveEndDate()
Description copied from interface: Sku
Returns the the last date that the Sku should be available for sale. This field is used to determine whether a user can add the sku to their cart.

Specified by:
getActiveEndDate in interface Sku

setActiveEndDate

public void setActiveEndDate(Date activeEndDate)
Description copied from interface: Sku
Sets the the last date that the Sku should be available for sale. This field is used to determine whether a user can add the sku to their cart.

Specified by:
setActiveEndDate in interface Sku

getDimension

public Dimension getDimension()
Description copied from interface: Sku
Get the dimensions for this Sku

Specified by:
getDimension in interface Sku
Returns:
this Sku's embedded Weight

setDimension

public void setDimension(Dimension dimension)
Description copied from interface: Sku
Sets the embedded Dimension for this Sku

Specified by:
setDimension in interface Sku

getWeight

public Weight getWeight()
Description copied from interface: Sku
Gets the embedded Weight for this Sku

Specified by:
getWeight in interface Sku
Returns:
this Sku's embedded Weight

setWeight

public void setWeight(Weight weight)
Description copied from interface: Sku
Sets the embedded Weight for this Sku

Specified by:
setWeight in interface Sku

isActive

public boolean isActive()
Description copied from interface: Sku
Returns a boolean indicating whether this sku is active. This is used to determine whether a user the sku can add the sku to their cart.

Specified by:
isActive in interface Sku

isActive

public boolean isActive(Product product,
                        Category category)
Description copied from interface: Sku
Returns whether or not this Sku, the given Product and the given Category are all active

Specified by:
isActive in interface Sku
Parameters:
product - - Product that should be active
category - - Category that should be active
Returns:
true if this Sku, product and category are all active false otherwise

getSkuMedia

public Map<String,Media> getSkuMedia()
Description copied from interface: Sku
Returns a map of key/value pairs where the key is a string for the name of a media object and the value is a media object.

Specified by:
getSkuMedia in interface Sku

setSkuMedia

public void setSkuMedia(Map<String,Media> skuMedia)
Description copied from interface: Sku
Sets a map of key/value pairs where the key is a string for the name of a media object and the value is an object of type Media.

Specified by:
setSkuMedia in interface Sku

getDefaultProduct

public Product getDefaultProduct()
Description copied from interface: Sku
This will be a value if and only if this Sku is the defaultSku of a Product (and thus has a @OneToOne relationship with a Product). The mapping for this is actually done at the Product level with a foreign key to Sku; this exists for convenience to get the reverse relationship

Specified by:
getDefaultProduct in interface Sku
Returns:
The associated Product if this Sku is a defaultSku, null otherwise
See Also:
Sku.getProduct()

setDefaultProduct

public void setDefaultProduct(Product defaultProduct)
Description copied from interface: Sku
The relationship for a Product's default Sku (and thus a Sku's default Product) is actually maintained on the Product entity as a foreign key to Sku. Because of this, there are probably very few circumstances that you would actually want to change this from the Sku perspective instead of the Product perspective.

If you are looking for a way to simply associate a Sku to a Product, the correct way would be to call Sku.setProduct(Product) or Product#setSkus(List) which would then cause this Sku to show up in the list of Skus for the given Product

Specified by:
setDefaultProduct in interface Sku

getProduct

public Product getProduct()
Description copied from interface: Sku
This will return the correct Product association that is being used on the Sku. If this Sku is a default Sku for a Product (as in, Sku.getDefaultProduct() != null) than this will return Sku.getDefaultProduct(). If this is not a default Sku for a Product, this will return the @ManyToOne Product relationship created by adding this Sku to a Product's list of Skus, or using Sku.setProduct(Product).

In some implementations, it might make sense to have both the @OneToOne association set (Product.setDefaultSku(Sku)) as well as the @ManyToOne association set (Sku.setProduct(Product)). In this case, This method would only return the result of Sku.getDefaultProduct(). However, the @OneToOne and @ManyToOne association should never actually refer to different Products, and would represent an error state. If you require this, consider subclassing and using your own @ManyToMany relationship between Product and Sku. If you are trying to model bundles, consider using a ProductBundle and subsequent SkuBundleItems.

Specified by:
getProduct in interface Sku
Returns:
Sku.getDefaultProduct() if Sku.getDefaultProduct() is non-null, the @ManyToOne Product association otherwise. If no relationship is set, returns null

setProduct

public void setProduct(Product product)
Description copied from interface: Sku
Associates a Sku to a given Product. This will then show up in the list returned by Product.getSkus()

Specified by:
setProduct in interface Sku
Parameters:
product - - Product to associate this Sku to
See Also:
Product.getSkus()

getSkuAttributes

public List<SkuAttribute> getSkuAttributes()
Description copied from interface: Sku
Denormalized set of key-value pairs to attach to a Sku. If you are looking for setting up a ProductOption scenario (like colors, sizes, etc) see Sku.getProductOptionValues() and setProductOptionValues()

Specified by:
getSkuAttributes in interface Sku
Returns:
the attributes for this Sku

getSkuAttributeByName

public SkuAttribute getSkuAttributeByName(String name)
Description copied from interface: Sku
Convenience method to return a given sku attribute by its name

Specified by:
getSkuAttributeByName in interface Sku
Returns:
the SkuAttribute

getMappedSkuAttributes

public Map<String,SkuAttribute> getMappedSkuAttributes()
Specified by:
getMappedSkuAttributes in interface Sku
Returns:
a Map of all the sku attributes on this sku keyed by the attribute name

getProductOptionValues

public List<ProductOptionValue> getProductOptionValues()
Description copied from interface: Sku
Gets the ProductOptionValues used to map to this Sku. For instance, this Sku could hold specific inventory, price and image information for a "Blue" "Extra-Large" shirt

Specified by:
getProductOptionValues in interface Sku
Returns:
the ProductOptionValues for this Sku
See Also:
ProductOptionValue}, {@link ProductOption}

setProductOptionValues

public void setProductOptionValues(List<ProductOptionValue> productOptionValues)
Description copied from interface: Sku
Sets the ProductOptionValues that should be mapped to this Sku

Specified by:
setProductOptionValues in interface Sku
See Also:
ProductOptionValue}, {@link ProductOption}

setSkuAttributes

public void setSkuAttributes(List<SkuAttribute> skuAttributes)
Description copied from interface: Sku
Sets the denormalized set of key-value pairs on a Sku

Specified by:
setSkuAttributes in interface Sku

isMachineSortable

public Boolean isMachineSortable()
Description copied from interface: Sku
Whether this Sku can be sorted by a machine

Specified by:
isMachineSortable in interface Sku
Returns:
true if this Sku can be sorted by a machine

setMachineSortable

public void setMachineSortable(Boolean isMachineSortable)
Description copied from interface: Sku
Sets whether or not this Sku can be sorted by a machine

Specified by:
setMachineSortable in interface Sku

getFees

public List<SkuFee> getFees()
Description copied from interface: Sku
Gets all the extra fees for this particular Sku. If the fee type is FULFILLMENT, these are stored on FulfillmentGroup.getFulfillmentGroupFees() for an Order

Specified by:
getFees in interface Sku
Returns:
the SkuFees for this Sku

setFees

public void setFees(List<SkuFee> fees)
Description copied from interface: Sku
Sets the extra fees for this particular Sku

Specified by:
setFees in interface Sku

getFulfillmentFlatRates

public Map<FulfillmentOption,BigDecimal> getFulfillmentFlatRates()
Description copied from interface: Sku
Gets the flat rate for fulfilling this Sku for a particular FulfillmentOption. Depending on the result of FulfillmentOption.getUseFlatRates(), this flat rate will be used in calculating the cost of fulfilling this Sku.

Specified by:
getFulfillmentFlatRates in interface Sku
Returns:
the flat rates for this Sku

setFulfillmentFlatRates

public void setFulfillmentFlatRates(Map<FulfillmentOption,BigDecimal> fulfillmentFlatRates)
Description copied from interface: Sku
Sets the flat rates for fulfilling this Sku for a particular FulfillmentOption. Depending on the result of FulfillmentOption.getUseFlatRates(), this flat rate will be used in calculating the cost of fulfilling this Sku.

Specified by:
setFulfillmentFlatRates in interface Sku

getExcludedFulfillmentOptions

public List<FulfillmentOption> getExcludedFulfillmentOptions()
Description copied from interface: Sku
Gets the FulfillmentOptions that this Sku should be excluded from. For instance, some Skus might not be available to be fulfilled next-day

Specified by:
getExcludedFulfillmentOptions in interface Sku
Returns:

setExcludedFulfillmentOptions

public void setExcludedFulfillmentOptions(List<FulfillmentOption> excludedFulfillmentOptions)
Description copied from interface: Sku
Sets the FulfillmentOptions that this Sku should be excluded from being apart of

Specified by:
setExcludedFulfillmentOptions in interface Sku

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2012. All Rights Reserved.