|
SalesPoint Framework v3.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--data.AbstractNameable | +--data.ooimpl.StockItemImpl | +--data.ooimpl.StockImpl
Pure Java implementation of the Stock
interface.
StockImpl Stocks can only work together with CatalogImpl
Catalogs,
StockItemImpl
StockItems and DataBasketImpl
DataBaskets.
Field Summary | |
protected CatalogChangeListener |
m_cclEditListener
Listens for editing events from the Catalog. |
protected CatalogImpl |
m_ciCatalog
The Catalog that is associated to this Stock. |
protected data.ooimpl.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. |
protected StockChangeListener |
m_sclEditCreatorListener
Listens to the creator, if this is a shallow copy that was created for editing purposes. |
Fields inherited from class data.AbstractNameable |
m_ncContext,
m_pcsPropertyListeners |
Constructor Summary | |
StockImpl(String sName,
CatalogImpl ciRef)
Create a new StockImpl. |
Method Summary | |
void |
addStock(Stock 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,
String sOldName,
String sNewName)
Check a name change of a StockItem that is contained in this Stock. |
Object |
clone()
Create and return a deep clone of the Stock. |
int |
compareTo(Object o)
Compare this StockItem to the given object. |
boolean |
contains(StockItem si,
DataBasket db)
Check whether the Stock contains the given StockItem. |
boolean |
contains(String sKey,
DataBasket db)
Check whether the Stock contains an item with the given key. |
boolean |
containsStock(Stock st,
DataBasket db)
Check whether the given Stock is completely contained in this Stock. |
protected abstract StockImpl |
createPeer()
Create an empty Stock with the same name, associated Catalog and class. |
protected void |
fillShallowClone(StockImpl 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 |
getCatalog(DataBasket db)
Get the Catalog associated to this Stock. |
protected Map |
getEditingItemsContainer()
Get the map of items that are currently being edited. |
protected Map |
getItemsContainer()
Get the map of items that are actually contained in the Stock. |
protected Object |
getItemsLock()
Get the monitor synchronizing access to the Stock's contents. |
Object |
getNCMonitor()
Stocks will not allow name changes of StockItem, as a principle. |
protected Map |
getRefIntegrEditContainer()
Get the map storing information about name changes in CatalogItems. |
protected Map |
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 Map |
getTemporaryAddedItemsContainer()
Get the map of items that have been temporaryly added to the Stock. |
protected Map |
getTemporaryRemovedItemsContainer()
Get the map of items that have been temporaryly removed from the Stock. |
protected void |
internalSetCatalog(CatalogImpl ciRef)
Set the Catalog that this Stock refers to. |
Iterator |
iterator(DataBasket db,
boolean fForEdit)
Iterate all items in the Stock. |
Set |
keySet(DataBasket db)
Return the set of keys for which StockItems are visible using the given DataBasket. |
void |
nameHasChanged(DataBasket db,
String sOldName,
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. |
void |
removeStockChangeListener(StockChangeListener scl)
Remove a listener that received events when the Stock's contents changed. |
protected void |
setEditingItemsContainer(Map mp)
Set the map of items that are currently being edited. |
protected void |
setItemsContainer(Map mp)
Set the map of items that are actually contained in the Stock. |
protected void |
setRefIntegrEditContainer(Map mp)
Set the map storing information about name changes in CatalogItems. |
protected void |
setRefIntegrItemsContainer(Map 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(Map mp)
Set the map of items that have been temporaryly added to the Stock. |
protected void |
setTemporaryRemovedItemsContainer(Map 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. |
Methods inherited from class data.ooimpl.StockItemImpl |
equals,
getAssociatedItem,
getStock,
toString |
Methods inherited from class 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 |
Field Detail |
protected CatalogImpl m_ciCatalog
protected DataBasket m_dbCatalogValidator
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.
protected ListenerHelper m_lhListeners
protected data.ooimpl.StockImpl.CatalogItemNameListener m_cinlCatalogItemNameListener
protected final CatalogChangeListener m_cclEditListener
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! This is not provided for in the
Framework.protected StockChangeListener m_sclEditCreatorListener
Constructor Detail |
public StockImpl(String sName, CatalogImpl ciRef)
sName
- the name of the new Stock.ciRef
- the Catalog that is referenced by this Stock.Method Detail |
protected final Object getItemsLock()
protected void internalSetCatalog(CatalogImpl ciRef)
m_dbCatalogValidator
will be set to
ciRef
- the Catalog to refer to from now on.
protected Map getItemsContainer()
protected Map getTemporaryAddedItemsContainer()
protected Map getTemporaryRemovedItemsContainer()
protected Map getEditingItemsContainer()
protected Map getRefIntegrItemsContainer()
protected Map getRefIntegrEditContainer()
protected void setItemsContainer(Map mp)
protected void setTemporaryAddedItemsContainer(Map mp)
protected void setTemporaryRemovedItemsContainer(Map mp)
protected void setEditingItemsContainer(Map mp)
protected void setRefIntegrItemsContainer(Map mp)
protected void setRefIntegrEditContainer(Map mp)
public void addStock(Stock st, DataBasket db, boolean fRemove)
Stock.add(data.StockItem, data.DataBasket)
for each item in the source
Stock so the same constraints apply and the same exceptions may be thrown.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.public boolean contains(String sKey, DataBasket db)
Equivalent to:(
.Stock.countItems(java.lang.String, data.DataBasket)
(sKey, db) > 0)
sKey
- the key for which to check containment.db
- the DataBasket used to check visibility. Must be either null
or a descendant of
DataBasketImpl
.public boolean contains(StockItem si, DataBasket db)
Return true if the Stock contains a StockItem that is equal to the given one.
si
- the StockItem for which to check containment.db
- the DataBasket used to check visibility. Must be either null
or a descendant of
DataBasketImpl
.public boolean containsStock(Stock st, DataBasket db)
Calls contains(data.StockItem, data.DataBasket)
for each item in the given Stock.
st
- the Stock for which to check containment.db
- the DataBasket used to determine visibility. Must be either null
or a descendant of
DataBasketImpl
.public Iterator iterator(DataBasket db, boolean fForEdit)
This method, together with Stock.get(java.lang.String, data.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
UnSupportedOperationException
s.
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.public Set keySet(DataBasket db)
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.
db
- the DataBasket used for determining visibility. Must be either null
or a descendant of
DataBasketImpl
.public Value sumStock(DataBasket db, CatalogItemValue civ, Value vInit)
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.
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.vInit
, only with a changed value.public Value fillStockWithValue(DataBasket db, Value vTarget, StockFromValueCreator sfvc)
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.
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.public int size(DataBasket db)
db
- the DataBasket used to determine visibility. Must be either null
or a descendant of
DataBasketImpl
.public Catalog getCatalog(DataBasket db)
public StockItemImpl getShallowClone()
createPeer()
and/or fillShallowClone(data.ooimpl.StockImpl)
.protected void fillShallowClone(StockImpl stiClone)
public Object clone()
createPeer()
.protected abstract StockImpl createPeer()
protected void setStock(StockImpl sti)
public int compareTo(Object o)
o
to be a StockItem and will
compare the names. Stocks, however, will always be greater than StockItems.StockItem
.public void checkNameChange(DataBasket db, String sOldName, String sNewName) throws NameContextException
Stocks will not allow name changes of StockItem, as a principle.
public void nameHasChanged(DataBasket db, String sOldName, String sNewName)
public Object getNCMonitor()
protected void prepareReferentialIntegrity(DataBasket db, DataBasketEntry dbe)
synchronized (getItemsLock()
) {}
before any other operation.public void addStockChangeListener(StockChangeListener scl)
public void removeStockChangeListener(StockChangeListener scl)
protected void fireStockItemsAdded(StockChangeEvent e)
protected void fireStockItemsAddCommit(StockChangeEvent e)
protected void fireStockItemsAddRollback(StockChangeEvent e)
protected void fireStockItemsRemoved(StockChangeEvent e)
protected void fireStockItemsRemoveCommit(StockChangeEvent e)
protected void fireStockItemsRemoveRollback(StockChangeEvent e)
protected void fireCanRemoveStockItems(StockChangeEvent e) throws VetoException
protected void fireCanEditStockItems(StockChangeEvent e) throws VetoException
protected void fireEditingStockItems(StockChangeEvent e)
protected void fireStockItemsEditCommit(StockChangeEvent e)
protected void fireStockItemsEditRollback(StockChangeEvent e)
|
SalesPoint Framework v3.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |