com.elasticpath.domain.catalog.impl
Class ProductAssociationImpl

java.lang.Object
  extended by com.elasticpath.domain.impl.AbstractEpDomainImpl
      extended by com.elasticpath.domain.impl.AbstractPersistenceImpl
          extended by com.elasticpath.domain.impl.AbstractValueObjectImpl
              extended by com.elasticpath.domain.catalog.impl.ProductAssociationImpl
All Implemented Interfaces:
ProductAssociation, EpDomain, Persistence, ValueObject, java.io.Serializable

public class ProductAssociationImpl
extends AbstractValueObjectImpl
implements ProductAssociation

Represents a link between two products for the purpose of displaying information about related products when viewing a particular product. Terminology: Source Product - The product that the user is viewing when additional products are to be displayed, e.g. for upselling to a more expensive product. Target Product - The other product that is to be displayed when viewing the source product.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Fields inherited from interface com.elasticpath.domain.catalog.ProductAssociation
ACCESSORY, ALL_ASSOCIATION_TYPE_NAMES, ALL_ASSOCIATION_TYPES, CROSS_SELL, RECOMMENDATION, REPLACEMENT, UP_SELL, WARRANTY
 
Constructor Summary
ProductAssociationImpl()
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if this object equals to the given object.
 int getAssociationType()
          Get the type of this ProductAssociation.
 int getDefaultQuantity()
          Get the default quantity of the product targeted by this MerchandiseAssociation.
 java.util.Date getEndDate()
          Get the end date after which this MerchandiseAssociation is no longer valid for display.
 int getOrdering()
          Get the order in which this product should appear on the page relative to other products having the same source product.
 java.util.Date getStartDate()
          Get the starting date on which this MerchandiseAssociation is valid for display.
 Product getTargetProduct()
          Get the product targeted by this association.
 ProductSku getTargetSku()
          Get the specific SKU targeted by this association.
 int hashCode()
          Generate the hash code.
 boolean isSourceProductDependent()
          Returns true if the product targeted by this MerchandiseAssociation depends on the source product such that it should be removed from the cart if the source product is removed.
 boolean isValid()
          Returns true if this association is valid because the current date is within the start and end dates.
 boolean isValidAssociationType(int associationType)
          Returns true if the given association type is valid.
 void setAssociationType(int associationType)
          Set the type of this ProductAssociation.
 void setDefaultQuantity(int defaultQuantity)
          Set the default quantity of the product targeted by this MerchandiseAssociation.
 void setDefaultValues()
          Set default values for those fields need default values.
 void setEndDate(java.util.Date endDate)
          Set the end date after which this MerchandiseAssociation is no longer valid for display.
 void setOrdering(int ordering)
          Set the order in which this product should appear on the page relative to other products having the same source product.
 void setSourceProductDependent(boolean sourceProductDependent)
          Set to true if the product targeted by this MerchandiseAssociation depends on the source product such that it should be removed from the cart if the source product is removed.
 void setStartDate(java.util.Date startDate)
          Set the starting date on which this MerchandiseAssociation is valid for display.
 void setTargetProduct(Product targetProduct)
          Set the target product.
 void setTargetSku(ProductSku targetSku)
          Set the specific SKU to be targeted by this association.
 
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

ProductAssociationImpl

public ProductAssociationImpl()
Method Detail

equals

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

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

getAssociationType

public int getAssociationType()
Get the type of this ProductAssociation.

Specified by:
getAssociationType in interface ProductAssociation
Returns:
the association type

getDefaultQuantity

public int getDefaultQuantity()
Get the default quantity of the product targeted by this MerchandiseAssociation. If no default quantity has been set, the default defaultQuantity is 1. If the target product is added to the cart automatically, it should be added in this default quantity.

Specified by:
getDefaultQuantity in interface ProductAssociation
Returns:
the default quantity of the target product

getEndDate

public java.util.Date getEndDate()
Get the end date after which this MerchandiseAssociation is no longer valid for display.

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

getOrdering

public int getOrdering()
Get the order in which this product should appear on the page relative to other products having the same source product.

Specified by:
getOrdering in interface ProductAssociation
Returns:
the ordering

getStartDate

public java.util.Date getStartDate()
Get the starting date on which this MerchandiseAssociation is valid for display.

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

getTargetProduct

public Product getTargetProduct()
Get the product targeted by this association. This is the product that is to be displayed when viewing the source product.

Specified by:
getTargetProduct in interface ProductAssociation
Returns:
the target product

getTargetSku

public ProductSku getTargetSku()
Get the specific SKU targeted by this association. If no SKU is specified, the product's default SKU will be returned.

Specified by:
getTargetSku in interface ProductAssociation
Returns:
the ProductSku

hashCode

public int hashCode()
Generate the hash code.

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

isSourceProductDependent

public boolean isSourceProductDependent()
Returns true if the product targeted by this MerchandiseAssociation depends on the source product such that it should be removed from the cart if the source product is removed.

Specified by:
isSourceProductDependent in interface ProductAssociation
Returns:
true if the target product depends on the source product

isValid

public boolean isValid()
Returns true if this association is valid because the current date is within the start and end dates.

Specified by:
isValid in interface ProductAssociation
Returns:
true if the product association is available at today's date.

isValidAssociationType

public boolean isValidAssociationType(int associationType)
Returns true if the given association type is valid.

Specified by:
isValidAssociationType in interface ProductAssociation
Parameters:
associationType - the association type
Returns:
true if the given association type is valid

setAssociationType

public void setAssociationType(int associationType)
Set the type of this ProductAssociation.

Specified by:
setAssociationType in interface ProductAssociation
Parameters:
associationType - one of the association type constants defined in this interface

setDefaultQuantity

public void setDefaultQuantity(int defaultQuantity)
Set the default quantity of the product targeted by this MerchandiseAssociation.

Specified by:
setDefaultQuantity in interface ProductAssociation
Parameters:
defaultQuantity - the default quantity

setDefaultValues

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

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

setEndDate

public void setEndDate(java.util.Date endDate)
Set the end date after which this MerchandiseAssociation is no longer valid for display.

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

setOrdering

public void setOrdering(int ordering)
Set the order in which this product should appear on the page relative to other products having the same source product.

Specified by:
setOrdering in interface ProductAssociation
Parameters:
ordering - the ordering

setSourceProductDependent

public void setSourceProductDependent(boolean sourceProductDependent)
Set to true if the product targeted by this MerchandiseAssociation depends on the source product such that it should be removed from the cart if the source product is removed.

Specified by:
setSourceProductDependent in interface ProductAssociation
Parameters:
sourceProductDependent - sets whether the target product depends on the source product

setStartDate

public void setStartDate(java.util.Date startDate)
Set the starting date on which this MerchandiseAssociation is valid for display.

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

setTargetProduct

public void setTargetProduct(Product targetProduct)
Set the target product.

Specified by:
setTargetProduct in interface ProductAssociation
Parameters:
targetProduct - the target product

setTargetSku

public void setTargetSku(ProductSku targetSku)
Set the specific SKU to be targeted by this association.

Specified by:
setTargetSku in interface ProductAssociation
Parameters:
targetSku - the ProductSku