pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.component.shop.model
Class ShopVariant

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.util.entity.AbstractNamedEntity
          extended by org.torweg.pulse.util.entity.AbstractNamableEntity
              extended by org.torweg.pulse.site.content.Variant<T>
                  extended by org.torweg.pulse.site.content.AbstractBasicVariant<T>
                      extended by org.torweg.pulse.site.content.AbstractSummaryDescriptionVariant<StoreVariant>
                          extended by org.torweg.pulse.component.store.model.StoreVariant
                              extended by org.torweg.pulse.component.shop.model.ShopVariant
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<StoreVariant>, ExtendedJDOMable, JDOMable, ShopItem, StoreItem, IHasAlternativeImages, IHasMainImage, IHasVariants, ILinkCorretable, INameable, INamed

@Entity
public class ShopVariant
extends StoreVariant
implements ShopItem

Represents an article variant in the shop.

Version:
$Revision: 1979 $
Author:
Christian Schatt, Daniel Dietz
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.torweg.pulse.site.content.Variant
LOGGER
 
Constructor Summary
ShopVariant()
          Deprecated. 
ShopVariant(java.lang.String pOrderCode)
          The constructor that sets the order code of the ShopVariant.
 
Method Summary
 ShopVariant createCopy(Content content)
          Creates a non-persistent (therefore id = null) copy of the current ShopVariant.
 void decreaseStockBy(int amnt)
          Decreases the stock by the given amount.
 org.jdom.Element deserializeToJDOM()
          Returns the state of the ShopVariant as a JDOM Element.
 org.jdom.Element deserializeToJDOM(ServiceRequest pServiceRequest)
          Returns the state of the ShopVariant as a JDOM Element.
 java.lang.Integer getAbsoluteMaxOrderSize(User user)
          returns the absolute minimum order size of all Prices available to the given User.
 java.lang.Integer getAbsoluteMinOrderSize(User user)
          returns the absolute minimum order size of all Prices available to the given User.
 java.util.List<Price> getAvailablePrices(User user)
          returns a list of Prices which are available to the given User, ordered by Price.getAmount(), Price.getMinOrderSize().
 Price getBestPrice(User pUser, int pAmount)
          Returns the best Price for the given User and the given amount.
 java.util.Set<Price> getPrices()
          Returns the Prices of the ShopVariant.
 java.util.Set<Price> getPrices(Status s)
          returns all Prices with the given status.
 java.util.Set<Price> getPrices(Status s, int a)
          returns all Prices with the given status available for the given amount.
 java.lang.String getShopItemId()
          returns a string identifying the ShopItem, starting with v for Variants followed by the primary key.
 Status getStatus()
          Returns the Status of the ShopVariant.
 java.lang.Integer getStock()
          Returns the stock of the ShopVariant, or null, if the stock is not maintained for the ShopVariant.
 void increaseStockBy(int amnt)
          Increases the stock by the given amount.
 boolean isStockMaintainable()
          Determines whether the stock is maintainable for the ShopVariant.
 boolean isStockMaintained()
          Determines whether the stock is maintained for the ShopVariant.
 void setContent(Content pShopContent)
          Sets the ShopContent of the ShopVariant.
 void setPrices(java.util.Set<Price> pPrices)
          Sets the Prices of the ShopVariant.
 void setStatus(Status pStatus)
          Sets the Status of the ShopVariant.
 void setStock(java.lang.Integer pStock)
          Sets the stock of the ShopVariant.
 
Methods inherited from class org.torweg.pulse.component.store.model.StoreVariant
getAlternativeImages, getFullTextValue, getMainImage, getOrderCode, onVirtualFileSystemChange, setAlternativeImages, setMainImage, setOrderCode, updateAssociatedFiles
 
Methods inherited from class org.torweg.pulse.site.content.AbstractSummaryDescriptionVariant
getDescription, getDescriptionElement, getLinkCorrectables, setDescription
 
Methods inherited from class org.torweg.pulse.site.content.AbstractBasicVariant
getContent, getSummary, getSummaryElement, setSummary
 
Methods inherited from class org.torweg.pulse.site.content.Variant
addVariant, compareTo, equals, getAssociatedVirtualFiles, getAttachments, getParentVariant, getVariants, hashCode, processHTML, removeVariant, setAssociatedVirtualFiles, setAttachments, setVariants, updateHTML
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamableEntity
setName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamedEntity
getName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, getFullQualifiedClassNameJAXB, getId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.torweg.pulse.component.store.model.StoreItem
equals, getAlternativeImages, getAssociatedVirtualFiles, getAttachments, getDescription, getDescriptionElement, getFullTextValue, getId, getMainImage, getOrderCode, getSummary, getSummaryElement, hashCode, onVirtualFileSystemChange, setAlternativeImages, setAssociatedVirtualFiles, setAttachments, setDescription, setMainImage, setOrderCode, setSummary
 
Methods inherited from interface org.torweg.pulse.util.INameable
setName
 
Methods inherited from interface org.torweg.pulse.util.INamed
getName
 
Methods inherited from interface org.torweg.pulse.site.content.IHasVariants
getVariants
 

Constructor Detail

ShopVariant

@Deprecated
public ShopVariant()
Deprecated. 

The default constructor used by HibernateTM.


ShopVariant

public ShopVariant(java.lang.String pOrderCode)
The constructor that sets the order code of the ShopVariant.

Parameters:
pOrderCode - the order code to be set.
Method Detail

getShopItemId

public final java.lang.String getShopItemId()
returns a string identifying the ShopItem, starting with v for Variants followed by the primary key.

Specified by:
getShopItemId in interface ShopItem
Returns:
the shop item id
See Also:
ShopItem.getShopItemId()

setContent

public void setContent(Content pShopContent)
Sets the ShopContent of the ShopVariant.

Overrides:
setContent in class StoreVariant
Parameters:
pShopContent - the ShopContent to be set.

getStatus

public final Status getStatus()
Returns the Status of the ShopVariant.

Specified by:
getStatus in interface ShopItem
Returns:
the Status of the ShopVariant.

setStatus

public final void setStatus(Status pStatus)
Sets the Status of the ShopVariant.

Specified by:
setStatus in interface ShopItem
Parameters:
pStatus - the Status to be set.

getPrices

public final java.util.Set<Price> getPrices()
Returns the Prices of the ShopVariant.

Specified by:
getPrices in interface ShopItem
Returns:
the Prices of the ShopVariant. (reference)

getPrices

public final java.util.Set<Price> getPrices(Status s)
returns all Prices with the given status.

Specified by:
getPrices in interface ShopItem
Parameters:
s - the status
Returns:
a set with all matching Prices

getPrices

public final java.util.Set<Price> getPrices(Status s,
                                            int a)
returns all Prices with the given status available for the given amount.

Specified by:
getPrices in interface ShopItem
Parameters:
s - the status
a - the amount
Returns:
a set with all matching Prices

setPrices

public final void setPrices(java.util.Set<Price> pPrices)
Sets the Prices of the ShopVariant.

Specified by:
setPrices in interface ShopItem
Parameters:
pPrices - the Prices to be set. (overwrite matching)

getBestPrice

public final Price getBestPrice(User pUser,
                                int pAmount)
Returns the best Price for the given User and the given amount.

Specified by:
getBestPrice in interface ShopItem
Parameters:
pUser - the User to get the best Price for.
pAmount - the amount of items the best Price has to be valid for.
Returns:
the best Price for the given User and the given amount.

getAbsoluteMinOrderSize

public final java.lang.Integer getAbsoluteMinOrderSize(User user)
returns the absolute minimum order size of all Prices available to the given User.

Specified by:
getAbsoluteMinOrderSize in interface ShopItem
Parameters:
user - the user
Returns:
the absolute minimum order size
See Also:
ShopItem.getAbsoluteMinOrderSize(org.torweg.pulse.accesscontrol.User)

getAbsoluteMaxOrderSize

public final java.lang.Integer getAbsoluteMaxOrderSize(User user)
returns the absolute minimum order size of all Prices available to the given User.

Specified by:
getAbsoluteMaxOrderSize in interface ShopItem
Parameters:
user - the user
Returns:
the absolute minimum order size
See Also:
ShopItem.getAbsoluteMinOrderSize(org.torweg.pulse.accesscontrol.User)

getAvailablePrices

public final java.util.List<Price> getAvailablePrices(User user)
returns a list of Prices which are available to the given User, ordered by Price.getAmount(), Price.getMinOrderSize().

Specified by:
getAvailablePrices in interface ShopItem
Parameters:
user - the user
Returns:
a list of Prices
See Also:
ShopItem.getAvailablePrices(User)

getStock

public final java.lang.Integer getStock()
Returns the stock of the ShopVariant, or null, if the stock is not maintained for the ShopVariant.

Specified by:
getStock in interface ShopItem
Returns:
the stock of the ShopVariant, or null

setStock

public final void setStock(java.lang.Integer pStock)
Sets the stock of the ShopVariant. If the given stock is null, it means that the stock is not maintained for the ShopVariant.

Specified by:
setStock in interface ShopItem
Parameters:
pStock - the stock to set, or null
Throws:
java.lang.IllegalStateException - if there are ShopVariants associated with the ShopVariant and the given stock is not null

isStockMaintainable

public final boolean isStockMaintainable()
Determines whether the stock is maintainable for the ShopVariant.

Specified by:
isStockMaintainable in interface ShopItem
Returns:
true if the stock is maintainable for the ShopVariant. Returns false, otherwise.

isStockMaintained

public final boolean isStockMaintained()
Determines whether the stock is maintained for the ShopVariant.

Specified by:
isStockMaintained in interface ShopItem
Returns:
true if the stock is maintained for the ShopVariant. Returns false, otherwise.
See Also:
ShopItem.isStockMaintained()

increaseStockBy

public final void increaseStockBy(int amnt)
Increases the stock by the given amount.

Specified by:
increaseStockBy in interface ShopItem
Parameters:
amnt - the amount
Throws:
java.lang.IllegalStateException - if the stock is not maintained for the ShopVariant
See Also:
ShopItem.increaseStockBy(int)

decreaseStockBy

public final void decreaseStockBy(int amnt)
Decreases the stock by the given amount.

Specified by:
decreaseStockBy in interface ShopItem
Parameters:
amnt - the amount
Throws:
java.lang.IllegalStateException - if the stock is not maintained for the ShopVariant
See Also:
ShopItem.decreaseStockBy(int)

deserializeToJDOM

public org.jdom.Element deserializeToJDOM()
Returns the state of the ShopVariant as a JDOM Element.

Specified by:
deserializeToJDOM in interface JDOMable
Overrides:
deserializeToJDOM in class StoreVariant
Returns:
the state of the ShopVariant as a JDOM Element.

deserializeToJDOM

public org.jdom.Element deserializeToJDOM(ServiceRequest pServiceRequest)
Returns the state of the ShopVariant as a JDOM Element.

Specified by:
deserializeToJDOM in interface ExtendedJDOMable
Overrides:
deserializeToJDOM in class StoreVariant
Parameters:
pServiceRequest - the current ServiceRequest or null.
Returns:
the state of the ShopVariant as a JDOM Element.

createCopy

public ShopVariant createCopy(Content content)
Creates a non-persistent (therefore id = null) copy of the current ShopVariant.

Overrides:
createCopy in class StoreVariant
Parameters:
content - the parent Content
Returns:
a copy of the ShopVariant.