|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | 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 |
Fields inherited from interface data.Nameable |
NAME_PROPERTY |
Fields inherited from interface data.DataBasketKeys |
CATALOG_ITEM_MAIN_KEY, STOCK_ITEM_MAIN_KEY |
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 |
Methods inherited from interface data.Stock |
add, countItems, get, remove, remove |
Methods inherited from interface data.StockItem |
getAssociatedItem, getStock |
Methods inherited from interface data.Nameable |
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName |
Methods inherited from interface data.ooimpl.SelfManagingDBESource |
commitRemove, rollbackRemove |
Methods inherited from interface data.ooimpl.SelfManagingDBEDestination |
commitAdd, rollbackAdd |
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! Preventing that is not provided by
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 null
.
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.
addStock
in interface Stock
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)
contains
in interface Stock
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.
contains
in interface Stock
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.
containsStock
in interface 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.
iterator
in interface Stock
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)
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.
keySet
in interface Stock
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.
sumStock
in interface Stock
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)
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.
fillStockWithValue
in interface Stock
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)
size
in interface Stock
db
- the DataBasket used to determine visibility. Must be either null
or a descendant of
DataBasketImpl
.public Catalog getCatalog(DataBasket db)
getCatalog
in interface Stock
db
- a DataBasket determinig visibility of the stock's catalog.public StockItemImpl getShallowClone()
deep clone
, the individual items in
the Stock are not cloned.
getShallowClone
in class StockItemImpl
createPeer()
and/or fillShallowClone(data.ooimpl.StockImpl)
.protected void fillShallowClone(StockImpl stiClone)
public Object clone()
shallow clone
, the
individual items themselves are also cloned.
clone
in interface StockItem
clone
in class StockItemImpl
createPeer()
.protected abstract StockImpl createPeer()
protected void setStock(StockImpl sti)
setStock
in class StockItemImpl
public int compareTo(Object o)
compareTo
in interface Comparable
compareTo
in class StockItemImpl
ClassCastException
- if the given object cannot be converted into a StockItem
.o
to be a StockItem and will
compare the names. Stocks, however, will always be greater than StockItems.public void checkNameChange(DataBasket db, String sOldName, String sNewName) throws NameContextException
Stocks will not allow name changes of StockItem, as a principle.
checkNameChange
in interface NameContext
db
- the DataBasket relative to which the name change is to take place.sOldName
- the name to be changed.sNewName
- the new name.
NameContextException
- if the name change would not be valid.public void nameHasChanged(DataBasket db, String sOldName, String sNewName)
nameHasChanged
in interface NameContext
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.public Object getNCMonitor()
getNCMonitor
in interface NameContext
protected void prepareReferentialIntegrity(DataBasket db, DataBasketEntry dbe)
synchronized (getItemsLock()
) {}
before any other operation.
public void addStockChangeListener(StockChangeListener scl)
addStockChangeListener
in interface ListenableStock
scl
- the listenerpublic void removeStockChangeListener(StockChangeListener scl)
removeStockChangeListener
in interface ListenableStock
scl
- the listenerprotected 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
VetoException
protected void fireCanEditStockItems(StockChangeEvent e) throws VetoException
VetoException
protected void fireEditingStockItems(StockChangeEvent e)
protected void fireStockItemsEditCommit(StockChangeEvent e)
protected void fireStockItemsEditRollback(StockChangeEvent e)
|
SalesPoint Framework v3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |