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 ShopContent

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.Content
                  extended by org.torweg.pulse.site.content.AbstractBasicContent
                      extended by org.torweg.pulse.site.content.AbstractSummaryDescriptionContent
                          extended by org.torweg.pulse.component.store.model.StoreContent
                              extended by org.torweg.pulse.component.shop.model.ShopContent
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Content>, ExtendedJDOMable, JDOMable, ShopItem, StoreItem, IHasAlternativeImages, IHasMainImage, IHasVariants, ILinkCorretable, INameable, INamed

@Entity
public class ShopContent
extends StoreContent
implements ShopItem

Represents an article 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.AbstractBasicContent
DEFAULT_SUFFIX
 
Constructor Summary
ShopContent()
          Deprecated. 
ShopContent(java.util.Locale pLocale, Bundle pBundle)
          The constructor that sets the Locale and the Bundle of the ShopContent.
 
Method Summary
 ShopContent createCopy(java.util.Locale l, User u)
          Creates a non-persistent (therefore id = null) copy of the current ShopContent with the given Locale.
 void decreaseStockBy(int amnt)
          Decreases the stock by the given amount.
 org.jdom.Element deserializeToJDOM()
          Returns the state of the ShopContent as a JDOM Element.
 org.jdom.Element deserializeToJDOM(ServiceRequest pServiceRequest)
          Returns the state of the ShopContent 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 ShopContent.
 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 c for Contents followed by the primary key.
 Status getStatus()
          Returns the Status of the ShopContent.
 java.lang.Integer getStock()
          Returns the stock of the ShopContent, or null, if the stock is not maintained for the ShopContent.
 java.util.Set<? extends Variant<?>> getVariants()
          Returns the ShopVariants of the ShopContent.
 void increaseStockBy(int amnt)
          Increases the stock by the given amount.
 boolean isStockMaintainable()
          Determines whether the stock is maintainable for the ShopContent.
 boolean isStockMaintained()
          Determines whether the stock is maintained for the ShopContent.
 void setPrices(java.util.Set<Price> pPrices)
          Sets the Prices of the ShopContent.
 void setStatus(Status pStatus)
          Sets the Status of the ShopContent.
 void setStock(java.lang.Integer pStock)
          Sets the stock of the ShopContent.
 void setVariants(java.util.Set<? extends Variant<?>> pShopVariants)
          Sets the ShopVariants of the ShopContent.
 
Methods inherited from class org.torweg.pulse.component.store.model.StoreContent
getAlternativeImages, getFullTextValue, getLinkCorrectables, getMainImage, getOrderCode, isGroup, onVirtualFileSystemChange, setAlternativeImages, setMainImage, setOrderCode, updateAssociatedVirtualFiles
 
Methods inherited from class org.torweg.pulse.site.content.AbstractSummaryDescriptionContent
getDescription, getDescriptionElement, setDescription
 
Methods inherited from class org.torweg.pulse.site.content.AbstractBasicContent
getKeywords, getMetaDescription, getMetaKeywords, getSuffix, getSummary, getSummaryElement, getTitle, setKeywords, setMetaDescription, setMetaKeywords, setSuffix, setSummary, setTitle
 
Methods inherited from class org.torweg.pulse.site.content.Content
compareTo, equals, getAssociatedViews, getAssociatedVirtualFiles, getAttachments, getBundle, getCreated, getCreatedMillis, getCreator, getLastModified, getLastModifier, getLocale, getLocalizationMap, getLocalizationMapJAXB, getReferenceDuration, getViewTypes, hashCode, hasReferenceDuration, initLazyFields, initLazyImageGroups, initLazyVariants, processHTML, removeReferenceDuration, setAssociatedVirtualFiles, setAttachments, setBundle, setCreator, setLastModifier, setLocale, setLocalizationMap, setReferenceDuration, toString, updateHTML, updateLocalizationMap
 
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, finalize, getClass, hashCode, notify, notifyAll, 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
 

Constructor Detail

ShopContent

@Deprecated
public ShopContent()
Deprecated. 

The default constructor used by HibernateTM.


ShopContent

public ShopContent(java.util.Locale pLocale, Bundle pBundle)
The constructor that sets the Locale and the Bundle of the ShopContent.

Parameters:
pLocale - the Locale to be set.
pBundle - the Bundle to be set.
Method Detail

getShopItemId

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

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

getVariants

public java.util.Set<? extends Variant<?>> getVariants()
Returns the ShopVariants of the ShopContent.

Specified by:
getVariants in interface IHasVariants
Overrides:
getVariants in class StoreContent
Returns:
the ShopVariants of the ShopContent. (shallow copy)

setVariants

public void setVariants(java.util.Set<? extends Variant<?>> pShopVariants)
Sets the ShopVariants of the ShopContent.

Overrides:
setVariants in class StoreContent
Parameters:
pShopVariants - the ShopVariants to be set. (final)
Throws:
java.lang.IllegalStateException - if the order code and/or the stock is not null

getStatus

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

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

setStatus

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

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 ShopContent.

Specified by:
getPrices in interface ShopItem
Returns:
the Prices of the ShopContent. (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 ShopContent.

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 ShopContent, or null, if the stock is not maintained for the ShopContent.

Specified by:
getStock in interface ShopItem
Returns:
the stock of the ShopContent, or null
See Also:
ShopItem.getStock()

setStock

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

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 ShopContent and the given stock is not null
See Also:
ShopItem.setStock(Integer)

isStockMaintainable

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

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

isStockMaintained

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

Specified by:
isStockMaintained in interface ShopItem
Returns:
true if the stock is maintained for the ShopContent. 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 ShopContent
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 ShopContent
See Also:
ShopItem.decreaseStockBy(int)

deserializeToJDOM

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

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

deserializeToJDOM

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

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

createCopy

public ShopContent createCopy(java.util.Locale l, User u)
Creates a non-persistent (therefore id = null) copy of the current ShopContent with the given Locale.

Overrides:
createCopy in class StoreContent
Parameters:
l - the Locale to be used.
u - the User to be used as the creator/last modifier of the copied Content
Returns:
a copy of the ShopContent.