org.salespointframework.core.data
Class StockImpl<T,ST extends StockItemImpl,CT extends CatalogItemImpl>

java.lang.Object
  extended by org.salespointframework.core.data.AbstractNameable
      extended by org.salespointframework.core.data.StockItemImpl
          extended by org.salespointframework.core.data.StockImpl<T,ST,CT>
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, java.lang.Iterable<ST>, Recoverable, DatasourceChangeListener, ExternalModificationListener, DataBasketEntryDestination, DataBasketEntrySource, DataBasketKeys, ListenableStock<ST,CT>, Nameable, NameContext, SpItem, Stock<ST,CT>, StockItem, SelfManagingDBEDestination<ST>, SelfManagingDBESource<ST>
Direct Known Subclasses:
CountingStockImpl, StoringStockImpl

public abstract class StockImpl<T,ST extends StockItemImpl,CT extends CatalogItemImpl>
extends StockItemImpl
implements Stock<ST,CT>, ListenableStock<ST,CT>, NameContext, SelfManagingDBESource<ST>, SelfManagingDBEDestination<ST>, java.lang.Iterable<ST>

Pure Java implementation of the Stock interface.

StockImpl Stocks can only work together with CatalogImpl Catalogs, StockItemImpl StockItems and DataBasketImpl DataBaskets.

Since:
v2.0
Version:
2.0 19/08/1999
Author:
Steffen Zschaler

Nested Class Summary
(package private)  class StockImpl.CatalogItemNameListener
          PropertyChangeListener that reacts to name changes in CatalogItems that are currently being edited.
 
Field Summary
protected  CatalogChangeListener m_cclEditListener
          Listens for editing events from the Catalog.
protected  CatalogImpl<CT> m_ciCatalog
          The Catalog that is associated to this Stock.
protected  StockImpl.CatalogItemNameListener m_cinlCatalogItemNameListener
          The listener that listens to name changes in CatalogItems in the associated Catalog.
protected  DataBasket m_dbCatalogValidator
          The DataBasket that determines the visibility of the catalog associated with this Stock.
protected  ListenerHelper m_lhListeners
          The listeners listening for events from this Stock.
private  java.util.Map<java.lang.String,T> m_mpEditingItems
          The map of items that are currently being edited.
private  java.util.Map<java.lang.String,T> m_mpItems
          The map of items that are actually contained in the Stock.
private  java.util.Map<java.lang.String,java.lang.String> m_mpRefIntegrEdit
          A map storing information about name changes in CatalogItems.
private  java.util.Map<java.lang.String,T> m_mpRefIntegrItems
          The map of items that have been removed from the Stock to ensure referential integrity.
private  java.util.Map<java.lang.String,T> m_mpTemporaryAddedItems
          The map of items that have been temporaryly added to the Stock.
private  java.util.Map<java.lang.String,T> m_mpTemporaryRemovedItems
          The map of items that have been temporaryly removed from the Stock.
private  java.lang.Object m_oItemsLock
          The monitor synchronizing access to the Stock's contents.
protected  StockChangeListener m_sclEditCreatorListener
          Listens to the creator, if this is a shallow copy that was created for editing purposes.
private  StockChangeListener m_sclEditingListener
          Listens to the parent Stock of the creator, if this is a shallow copy that was created for editing purposes.
private  java.lang.ref.SoftReference<StockImpl> m_srsiEditCreator
          The original Stock, if this is a shallow copy that was created for editing purposes.
 
Fields inherited from class org.salespointframework.core.data.StockItemImpl
COMMIT_ACTION, ROLLBACK_ACTION, STARTEDIT_ACTION
 
Fields inherited from class org.salespointframework.core.data.AbstractNameable
m_ncContext, m_pcsPropertyListeners, SOME_PROPERTY
 
Fields inherited from interface org.salespointframework.core.data.interfaces.Nameable
NAME_PROPERTY
 
Fields inherited from interface org.salespointframework.core.data.interfaces.DataBasketKeys
CATALOG_ITEM_MAIN_KEY, STOCK_ITEM_MAIN_KEY
 
Constructor Summary
StockImpl(StockIdentifier<ST,CT> siId, CatalogImpl<CT> ciRef)
          Create a new StockImpl.
StockImpl(java.lang.String sName, CatalogImpl<CT> ciRef)
          Create a new StockImpl.
 
Method Summary
 void addStock(Stock<ST,CT> st, DataBasket db, boolean fRemove)
          Add the contents of a Stock to this Stock.
 void addStockChangeListener(StockChangeListener scl)
          Add a listener to receive events when the Stock's contents change.
 void checkNameChange(DataBasket db, java.lang.String sOldName, java.lang.String sNewName)
          Check a name change of a StockItem that is contained in this Stock.
 java.lang.Object clone()
          Create and return a deep clone of the Stock.
 int compareTo(java.lang.Object o)
          Compare this StockItem to the given object.
 boolean contains(ST si, DataBasket db)
          Check whether the Stock contains the given StockItem.
 boolean contains(java.lang.String sKey, DataBasket db)
          Check whether the Stock contains an item with the given key.
 boolean containsStock(Stock<ST,CT> st, DataBasket db)
          Check whether the given Stock is completely contained in this Stock.
protected abstract  StockImpl<T,ST,CT> createPeer()
          Create an empty Stock with the same name, associated Catalog and class.
 void DatasourceChanged(boolean pumpUp)
          handles a datasource change by pumping up the event to stock's listeners
 void externalModificationOccurred()
          simulates a datasource change to handle external modifications
protected  void fillShallowClone(StockImpl<T,ST,CT> stiClone)
          Hook method called to fill the given shallow clone of this Stock.
 Value fillStockWithValue(DataBasket db, Value vTarget, StockFromValueCreator sfvc)
          Increase the Stock's value by a given value.
protected  void fireCanEditStockItems(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireCanRemoveStockItems(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireEditingStockItems(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsAddCommit(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsAdded(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsAddRollback(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsEditCommit(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsEditRollback(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsRemoveCommit(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsRemoved(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
protected  void fireStockItemsRemoveRollback(StockChangeEvent e)
          Fire an event to all listeners that showed an interest in this Stock.
 Catalog<CT> getCatalog(DataBasket db)
          Get the Catalog associated to this Stock.
protected  java.util.Map<java.lang.String,T> getEditingItemsContainer()
          Get the map of items that are currently being edited.
protected  java.util.Map<java.lang.String,T> getItemsContainer()
          Get the map of items that are actually contained in the Stock.
protected  java.lang.Object getItemsLock()
          Get the monitor synchronizing access to the Stock's contents.
 java.lang.Object getNCMonitor()
          Stocks will not allow name changes of StockItem, as a principle.
protected  java.util.Map<java.lang.String,java.lang.String> getRefIntegrEditContainer()
          Get the map storing information about name changes in CatalogItems.
protected  java.util.Map<java.lang.String,T> getRefIntegrItemsContainer()
          Get the map of items that have been removed from the Stock to ensure referential integrity.
 StockItemImpl getShallowClone()
          Create a shallow clone of the Stock.
protected  java.util.Map<java.lang.String,T> getTemporaryAddedItemsContainer()
          Get the map of items that have been temporaryly added to the Stock.
protected  java.util.Map<java.lang.String,T> getTemporaryRemovedItemsContainer()
          Get the map of items that have been temporaryly removed from the Stock.
protected  void internalSetCatalog(CatalogImpl<CT> ciRef)
          Set the Catalog that this Stock refers to.
 java.util.Iterator<ST> iterator()
          Iterate all items in the Stock.
 java.util.Iterator<ST> iterator(DataBasket db, boolean fForEdit)
          Iterate all items in the Stock.
 java.util.Set<java.lang.String> keySet(DataBasket db)
          Return the set of keys for which StockItems are visible using the given DataBasket.
 void nameHasChanged(DataBasket db, java.lang.String sOldName, java.lang.String sNewName)
          Stocks will not allow name changes of StockItem, as a principle.
protected  void prepareReferentialIntegrity(DataBasket db, DataBasketEntry dbe)
          Helper method to be called in the beginning of commitAdd and rollbackRemove.
(package private)  void relinkCatalog(DataBasket db, int nAction)
          Helper method used to maintain StockImpl - CatalogImpl links in nested Stocks/Catalogs.
 void removeStockChangeListener(StockChangeListener scl)
          Remove a listener that received events when the Stock's contents changed.
protected  void setEditingItemsContainer(java.util.Map<java.lang.String,T> mp)
          Set the map of items that are currently being edited.
protected  void setItemsContainer(java.util.Map<java.lang.String,T> mp)
          Set the map of items that are actually contained in the Stock.
protected  void setRefIntegrEditContainer(java.util.Map<java.lang.String,java.lang.String> mp)
          Set the map storing information about name changes in CatalogItems.
protected  void setRefIntegrItemsContainer(java.util.Map<java.lang.String,T> mp)
          Set the map of items that have been removed from the Stock to ensure referential integrity.
protected  void setStock(StockImpl<?,?,?> sti)
          Set the Stock that contains this Stock.
protected  void setTemporaryAddedItemsContainer(java.util.Map<java.lang.String,T> mp)
          Set the map of items that have been temporaryly added to the Stock.
protected  void setTemporaryRemovedItemsContainer(java.util.Map<java.lang.String,T> mp)
          Set the map of items that have been temporaryly removed from the Stock.
 int size(DataBasket db)
          Get the size of this Stock.
 Value sumStock(DataBasket db, CatalogItemValue civ, Value vInit)
          Sum up the Stock.
 void unsubscribe()
          unsubscribe underlying map from PersistenceManager
 
Methods inherited from class org.salespointframework.core.data.StockItemImpl
equals, firePropertyChanged, getAssociatedItem, getStock, internalSetName, recover, toString
 
Methods inherited from class org.salespointframework.core.data.AbstractNameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.salespointframework.core.data.interfaces.Stock
add, countItems, get, remove, remove
 
Methods inherited from interface org.salespointframework.core.data.interfaces.StockItem
getAssociatedItem, getStock
 
Methods inherited from interface org.salespointframework.core.data.interfaces.Nameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from interface org.salespointframework.core.data.interfaces.SpItem
getName
 
Methods inherited from interface org.salespointframework.core.data.SelfManagingDBESource
commitRemove, rollbackRemove
 
Methods inherited from interface org.salespointframework.core.data.SelfManagingDBEDestination
commitAdd, rollbackAdd
 

Field Detail

m_ciCatalog

protected CatalogImpl<CT extends CatalogItemImpl> m_ciCatalog
The Catalog that is associated to this Stock.


m_dbCatalogValidator

protected DataBasket m_dbCatalogValidator
The DataBasket that determines the visibility of the catalog associated with this Stock.

If null, the associated Catalog is visible with any DataBasket, otherwise it is only visible with the DataBasket specified in this field. Requests for the Catalog using a different DataBasket will the be rejected by throwing a DataBasketConflictException.


m_lhListeners

protected ListenerHelper m_lhListeners
The listeners listening for events from this Stock.


m_mpItems

private java.util.Map<java.lang.String,T> m_mpItems
The map of items that are actually contained in the Stock.


m_mpTemporaryAddedItems

private java.util.Map<java.lang.String,T> m_mpTemporaryAddedItems
The map of items that have been temporaryly added to the Stock.


m_mpTemporaryRemovedItems

private java.util.Map<java.lang.String,T> m_mpTemporaryRemovedItems
The map of items that have been temporaryly removed from the Stock.


m_mpEditingItems

private java.util.Map<java.lang.String,T> m_mpEditingItems
The map of items that are currently being edited.


m_mpRefIntegrItems

private java.util.Map<java.lang.String,T> m_mpRefIntegrItems
The map of items that have been removed from the Stock to ensure referential integrity.


m_mpRefIntegrEdit

private java.util.Map<java.lang.String,java.lang.String> m_mpRefIntegrEdit
A map storing information about name changes in CatalogItems.

Key: new name.
Value: old name.

This map is needed for referential integrity.


m_oItemsLock

private transient java.lang.Object m_oItemsLock
The monitor synchronizing access to the Stock's contents.


m_cinlCatalogItemNameListener

protected StockImpl.CatalogItemNameListener m_cinlCatalogItemNameListener
The listener that listens to name changes in CatalogItems in the associated Catalog.


m_cclEditListener

protected final CatalogChangeListener m_cclEditListener
Listens for editing events from the Catalog. Installs m_cinlCatalogItemNameListener if necessary. Also prevents editing, if there are StockItems in DataBaskets, so that we don't get any problems with name changes. Note however, that it might be possible to first edit a CatalogItem and then remove corresponding StockItems which might cause the same problem! Preventing that is not provided by the Framework.


m_srsiEditCreator

private transient java.lang.ref.SoftReference<StockImpl> m_srsiEditCreator
The original Stock, if this is a shallow copy that was created for editing purposes. A SoftReference is used so that it can be removed when the last reference to the creator was deleted.


m_sclEditingListener

private final StockChangeListener m_sclEditingListener
Listens to the parent Stock of the creator, if this is a shallow copy that was created for editing purposes. It will cut the connection if the editing is either commited or rolled back.


m_sclEditCreatorListener

protected StockChangeListener m_sclEditCreatorListener
Listens to the creator, if this is a shallow copy that was created for editing purposes. This is to follow with any events that the creator might trigger.

Constructor Detail

StockImpl

public StockImpl(java.lang.String sName,
                 CatalogImpl<CT> ciRef)
Create a new StockImpl.

Parameters:
sName - the name of the new Stock.
ciRef - the Catalog that is referenced by this Stock.

StockImpl

public StockImpl(StockIdentifier<ST,CT> siId,
                 CatalogImpl<CT> ciRef)
Create a new StockImpl.

Parameters:
siId - the id of the new Stock.
ciRef - the Catalog that is referenced by this Stock.
Method Detail

getItemsLock

protected final java.lang.Object getItemsLock()
Get the monitor synchronizing access to the Stock's contents.


internalSetCatalog

protected void internalSetCatalog(CatalogImpl<CT> ciRef)
Set the Catalog that this Stock refers to. This method is only used internally.

m_dbCatalogValidator will be set to null.

Parameters:
ciRef - the Catalog to refer to from now on.

getItemsContainer

protected java.util.Map<java.lang.String,T> getItemsContainer()
Get the map of items that are actually contained in the Stock.


getTemporaryAddedItemsContainer

protected java.util.Map<java.lang.String,T> getTemporaryAddedItemsContainer()
Get the map of items that have been temporaryly added to the Stock.


getTemporaryRemovedItemsContainer

protected java.util.Map<java.lang.String,T> getTemporaryRemovedItemsContainer()
Get the map of items that have been temporaryly removed from the Stock.


getEditingItemsContainer

protected java.util.Map<java.lang.String,T> getEditingItemsContainer()
Get the map of items that are currently being edited.


getRefIntegrItemsContainer

protected java.util.Map<java.lang.String,T> getRefIntegrItemsContainer()
Get the map of items that have been removed from the Stock to ensure referential integrity.


getRefIntegrEditContainer

protected java.util.Map<java.lang.String,java.lang.String> getRefIntegrEditContainer()
Get the map storing information about name changes in CatalogItems.


setItemsContainer

protected void setItemsContainer(java.util.Map<java.lang.String,T> mp)
Set the map of items that are actually contained in the Stock.


setTemporaryAddedItemsContainer

protected void setTemporaryAddedItemsContainer(java.util.Map<java.lang.String,T> mp)
Set the map of items that have been temporaryly added to the Stock.


setTemporaryRemovedItemsContainer

protected void setTemporaryRemovedItemsContainer(java.util.Map<java.lang.String,T> mp)
Set the map of items that have been temporaryly removed from the Stock.


setEditingItemsContainer

protected void setEditingItemsContainer(java.util.Map<java.lang.String,T> mp)
Set the map of items that are currently being edited.


setRefIntegrItemsContainer

protected void setRefIntegrItemsContainer(java.util.Map<java.lang.String,T> mp)
Set the map of items that have been removed from the Stock to ensure referential integrity.


setRefIntegrEditContainer

protected void setRefIntegrEditContainer(java.util.Map<java.lang.String,java.lang.String> mp)
Set the map storing information about name changes in CatalogItems.


addStock

public void addStock(Stock<ST,CT> st,
                     DataBasket db,
                     boolean fRemove)
Add the contents of a Stock to this Stock. The method calls Stock.add(T, org.salespointframework.core.data.interfaces.DataBasket) for each item in the source Stock so the same constraints apply and the same exceptions may be thrown.

Specified by:
addStock in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
st - the Stock whose contents is to be added to this Stock.
db - the DataBasket relative to which to perform the actions. addStock will add all items from the source Stock that are visible using this DataBasket. Must be either null or a descendant of DataBasketImpl.
fRemove - if true, the items will be removed from the source Stock prior to adding them to this Stock. Otherwise, they will be cloned prior to adding them to the Stock.

contains

public boolean contains(java.lang.String sKey,
                        DataBasket db)
Check whether the Stock contains an item with the given key.

Equivalent to:(Stock.countItems(java.lang.String, org.salespointframework.core.data.interfaces.DataBasket) (sKey, db) > 0).

Specified by:
contains in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
sKey - the key for which to check containment.
db - the DataBasket used to check visibility. Must be either null or a descendant of DataBasketImpl.

contains

public boolean contains(ST si,
                        DataBasket db)
Check whether the Stock contains the given StockItem.

Return true if the Stock contains a StockItem that is equal to the given one.

Specified by:
contains in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
si - the StockItem for which to check containment.
db - the DataBasket used to check visibility. Must be either null or a descendant of DataBasketImpl.

containsStock

public boolean containsStock(Stock<ST,CT> st,
                             DataBasket db)
Check whether the given Stock is completely contained in this Stock.

Calls Stock.contains(org.salespointframework.core.data.interfaces.StockItem, org.salespointframework.core.data.interfaces.DataBasket) for each item in the given Stock.

Specified by:
containsStock in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
st - the Stock for which to check containment.
db - the DataBasket used to determine visibility. Must be either null or a descendant of DataBasketImpl.

iterator

public java.util.Iterator<ST> iterator()
Iterate all items in the Stock.

Specified by:
iterator in interface java.lang.Iterable<ST extends StockItemImpl>
See Also:
called with databasket = null and foredit = false

iterator

public java.util.Iterator<ST> iterator(DataBasket db,
                                       boolean fForEdit)
Iterate all items in the Stock.

This method, together with Stock.get(java.lang.String, org.salespointframework.core.data.interfaces.DataBasket, boolean) is the only way of accessing the individual StockItems contained in a Stock. The iterator will deliver all items that are visible using the given DataBasket. Depending on the fForEdit parameter, the items will be retrieved in different ways. See DataBasket for an explanation of the different possibilities.

canEditStockItems and editingStockItems events will be fired if fForEdit == true. VetoExceptions will be converted into UnSupportedOperationExceptions.

Specified by:
iterator in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
db - the DataBasket relative to which to retrieve the StockItems. Must be either null or a descendant of DataBasketImpl.
fForEdit - if true, the StockItems will be retrieved for editing.

keySet

public java.util.Set<java.lang.String> keySet(DataBasket db)
Return the set of keys for which StockItems are visible using the given DataBasket.

The returned set is static and gives the state of the Stock at the time of the call. It will not automatically update when the contents of the Stock changes.

Specified by:
keySet in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
db - the DataBasket used for determining visibility. Must be either null or a descendant of DataBasketImpl.

sumStock

public Value sumStock(DataBasket db,
                      CatalogItemValue civ,
                      Value vInit)
Sum up the Stock.

The method will determine the value of each CatalogItem in the associated Catalog and multiply this by the number of StockItems for the respective key. These products will be added up and the resulting total will be returned.

Specified by:
sumStock in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
db - the DataBasket that is used to determine visibility. Must be either null or a descendant of DataBasketImpl.
civ - the CatalogItemValue used for determining the value of a CatalogItem.
vInit - the initial value. The sum of the Stock will be added to this value.
Returns:
the resulting total. Usually the returned object is the same as the one passed as vInit, only with a changed value.

fillStockWithValue

public Value fillStockWithValue(DataBasket db,
                                Value vTarget,
                                StockFromValueCreator sfvc)
Increase the Stock's value by a given value.

The method will try to break the given value as exactly as possible into StockItems that will be added to the Stock. The actual algorithm used for breaking up the value will be determined by the last parameter. The return value of the method will specify the remaining value that could not be represented by StockItems by the given algorithm.

Specified by:
fillStockWithValue in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
db - the DataBasket relative to which to perform the operation. Must be either null or a descendant of DataBasketImpl.
vTarget - the value by which to increase the Stock's total value.
sfvc - the strategy used to fill the Stock.
Returns:
the value that remained and could not be represented by StockItems.

size

public int size(DataBasket db)
Get the size of this Stock. I.e. calculate the number of StockItems that can be seen when using the given DataBasket.

Specified by:
size in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
db - the DataBasket used to determine visibility. Must be either null or a descendant of DataBasketImpl.

getCatalog

public Catalog<CT> getCatalog(DataBasket db)
Get the Catalog associated to this Stock.

Specified by:
getCatalog in interface Stock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
db - a DataBasket determinig visibility of the stock's catalog.

getShallowClone

public StockItemImpl getShallowClone()
Create a shallow clone of the Stock. In contrast to a deep clone, the individual items in the Stock are not cloned.

Overrides:
getShallowClone in class StockItemImpl

fillShallowClone

protected void fillShallowClone(StockImpl<T,ST,CT> stiClone)
Hook method called to fill the given shallow clone of this Stock.


clone

public java.lang.Object clone()
Create and return a deep clone of the Stock. In contrast to a shallow clone, the individual items themselves are also cloned.

Specified by:
clone in interface StockItem
Overrides:
clone in class StockItemImpl

createPeer

protected abstract StockImpl<T,ST,CT> createPeer()
Create an empty Stock with the same name, associated Catalog and class.


setStock

protected void setStock(StockImpl<?,?,?> sti)
Set the Stock that contains this Stock.

Overrides:
setStock in class StockItemImpl

compareTo

public int compareTo(java.lang.Object o)
Compare this StockItem to the given object.

Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>
Overrides:
compareTo in class StockItemImpl
Throws:
java.lang.ClassCastException - if the given object cannot be converted into a StockItem.

checkNameChange

public void checkNameChange(DataBasket db,
                            java.lang.String sOldName,
                            java.lang.String sNewName)
                     throws NameContextException
Check a name change of a StockItem that is contained in this Stock.

Stocks will not allow name changes of StockItem, as a principle.

Specified by:
checkNameChange in interface NameContext
Parameters:
db - the DataBasket relative to which the name change is to take place.
sOldName - the name to be changed.
sNewName - the new name.
Throws:
NameContextException - if the name change would not be valid.

nameHasChanged

public void nameHasChanged(DataBasket db,
                           java.lang.String sOldName,
                           java.lang.String sNewName)
Stocks will not allow name changes of StockItem, as a principle.

Specified by:
nameHasChanged in interface NameContext
Parameters:
db - the DataBasket relative to which the name change has taken place.
sOldName - the old name of the object whose name was changed.
sNewName - the new name of the object.

getNCMonitor

public java.lang.Object getNCMonitor()
Stocks will not allow name changes of StockItem, as a principle.

Specified by:
getNCMonitor in interface NameContext

prepareReferentialIntegrity

protected void prepareReferentialIntegrity(DataBasket db,
                                           DataBasketEntry dbe)
Helper method to be called in the beginning of commitAdd and rollbackRemove. Tries to maintain referential integrity by trying to make sure that a CatalogItem exists for the the StockItems that will be brought into the Stock. Must be called from within synchronized (getItemsLock()) {} before any other operation.


addStockChangeListener

public void addStockChangeListener(StockChangeListener scl)
Add a listener to receive events when the Stock's contents change.

Specified by:
addStockChangeListener in interface ListenableStock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
scl - the listener

removeStockChangeListener

public void removeStockChangeListener(StockChangeListener scl)
Remove a listener that received events when the Stock's contents changed.

Specified by:
removeStockChangeListener in interface ListenableStock<ST extends StockItemImpl,CT extends CatalogItemImpl>
Parameters:
scl - the listener

fireStockItemsAdded

protected void fireStockItemsAdded(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsAddCommit

protected void fireStockItemsAddCommit(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsAddRollback

protected void fireStockItemsAddRollback(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsRemoved

protected void fireStockItemsRemoved(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsRemoveCommit

protected void fireStockItemsRemoveCommit(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsRemoveRollback

protected void fireStockItemsRemoveRollback(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireCanRemoveStockItems

protected void fireCanRemoveStockItems(StockChangeEvent e)
                                throws VetoException
Fire an event to all listeners that showed an interest in this Stock.

Throws:
VetoException

fireCanEditStockItems

protected void fireCanEditStockItems(StockChangeEvent e)
                              throws VetoException
Fire an event to all listeners that showed an interest in this Stock.

Throws:
VetoException

fireEditingStockItems

protected void fireEditingStockItems(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsEditCommit

protected void fireStockItemsEditCommit(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


fireStockItemsEditRollback

protected void fireStockItemsEditRollback(StockChangeEvent e)
Fire an event to all listeners that showed an interest in this Stock.


relinkCatalog

void relinkCatalog(DataBasket db,
                   int nAction)
Helper method used to maintain StockImpl - CatalogImpl links in nested Stocks/Catalogs. For internal use only.

Overrides:
relinkCatalog in class StockItemImpl
Parameters:
db - the DataBasket that protecting this activity.
nAction - the action that occurred. Can be either StockItemImpl.COMMIT_ACTION, StockItemImpl.ROLLBACK_ACTION, StockItemImpl.STARTEDIT_ACTION.

DatasourceChanged

public void DatasourceChanged(boolean pumpUp)
handles a datasource change by pumping up the event to stock's listeners

Specified by:
DatasourceChanged in interface DatasourceChangeListener
Parameters:
pumpUp - true if the event should be pumped up to hosts, because this event is mostly triggered twice. first time to invalidate caches. second time for load new data

unsubscribe

public void unsubscribe()
unsubscribe underlying map from PersistenceManager


externalModificationOccurred

public void externalModificationOccurred()
simulates a datasource change to handle external modifications

Specified by:
externalModificationOccurred in interface ExternalModificationListener