SalesPoint Framework v3.0

sale
Class SalesPoint

java.lang.Object
  |
  +--sale.SalesPoint

public class SalesPoint
extends Object
implements ProcessContext, FormSheetListener, SerializableListener

A single point of sale in a shop.

SalesPoints represent single points of sale in a Shop at which user interaction occurs. Examples for such SalesPoints are cash counters, box offices, ticket vending machines etc.

Normally, you will have at least one SalesPoint in your application.

Services available at SalesPoints are implemented as processes. There can be at most one process running at a SalesPoint at any given point of time.

SalesPoints are process contexts to the processes running at them. They provide data and log access, as well as a display and current user. When a SalesPoint is created, a display is attached to it, which will be used by the process.

A user can be attached to the SalesPoint. Its capabilities will determine what can and cannot be done at the SalesPoint.

Hooks:
Add a new point of sale , Change A SalesPoint's Quit Conditions , Define new FormSheet for point of sale , Define new MenuSheet for a point of sale , Define new Status FormSheet for point of sale , Define new status MenuSheet for a point of sale , Incorporate a process that needs user interaction , Log Opening And Closing Of SalesPoints
Since:
v1.0
Version:
2.0 15/07/1999
Author:
Steffen Zschaler
See Also:
Serialized Form

Field Summary
protected  SaleProcess m_pCurProcess
          The process currently running on this SalesPoint, if any.
 
Constructor Summary
SalesPoint(String sName)
          Create a new SalesPoint.
 
Method Summary
 DataBasket attach(DataBasket db)
          Attach a DataBasket to this SalesPoint.
 Display attach(Display d)
          Attach a new display to the SalesPoint.
 User attach(User usr)
          Attach a user to this SalesPoint.
protected  Display attachStatusDisplay(Display dStatus)
          Attach a status display to the SalesPoint.
protected  boolean canQuit(boolean fNoPersistence)
          Check whether this SalesPoint can be closed.
 DataBasket detachBasket()
          Detach any DataBasket currently attached to this SalesPoint.
 Display detachDisplay()
          Detach the current display.
protected  Display detachStatusDisplay()
          Detach the current status display.
 User detachUser()
          Detach any user currently attached to this SalesPoint.
 void formSheetRemoved(FormSheetEvent e)
          Implemented to make sure there always is a FormSheet.
 void formSheetSet(FormSheetEvent e)
          Dummy interface to conform by the FormSheetListener interface.
 DataBasket getBasket()
          Get the DataBasket currently attached to this SalesPoint.
 Catalog getCatalog(String sName)
          Return a Catalog for a given name.
 SaleProcess getCurrentProcess()
          Get the process currently running on this SalesPoint, if any.
 User getCurrentUser(SaleProcess p)
          Get the current user for the given process.
protected  FormSheet getDefaultFormSheet()
          Get the default FormSheet for this SalesPoint.
protected  MenuSheet getDefaultMenuSheet()
          Get the default MenuSheet for this SalesPoint.
protected  FormSheet getDefaultStatusFormSheet()
          Get the default status FormSheet for this SalesPoint.
protected  MenuSheet getDefaultStatusMenuSheet()
          Get the default status MenuSheet for this SalesPoint.
 Display getDisplay()
          Return the display of this SalesPoint.
 String getName()
          Return the name of this SalesPoint.
protected  Object getProcessLock()
          Return the monitor synchronizing process access.
 Rectangle getSalesPointFrameBounds()
          Returns the Framebounds of the SalesPoints assoziated Display(JDisplayFrame).
 Stock getStock(String sName)
          Return a Stock for a given name.
 User getUser()
          Get the user currently attached to this SalesPoint.
 boolean hasUseableDisplay(SaleProcess p)
          True, if the SalesPoint currently has a display and this display is useable.
 void log(SaleProcess p, Loggable la)
          Log the given Loggable.
protected  void logSalesPointClosed()
          Hook method called when the SalesPoint is removed from a Shop.
protected  void logSalesPointOpened()
          Hook method called when the SalesPoint is added to a Shop.
protected  boolean onCanQuit()
          Hook method called to determine whether a SalesPoint with no process running on it can be closed by an explicit quit call.
 void popUpFormSheet(SaleProcess p, FormSheet fs)
          Allow a process to pop up a FormSheet on the SalesPoint's current display.
 void processFinished(SaleProcess p)
          Notification that a process finished running on this SalesPoint.
 void processStarted(SaleProcess p)
          Notification that a process started on a SalesPoint.
 void quit()
          Close the SalesPoint.
 void resume()
          Resume the SalesPoint.
 void runProcess(SaleProcess p)
          Start a process on this SalesPoint.
 void setFormSheet(SaleProcess p, FormSheet fs)
          Allow a process to set a FormSheet on the SalesPoint's current display.
 void setMenuSheet(SaleProcess p, MenuSheet ms)
          Allow a process to set a MenuSheet on the SalesPoint's current display.
 void setSalesPointFrameBounds(Rectangle r)
          Sets the Framebounds of the SalesPoints assoziated Display (JDisplayFrame).
protected  void setStatusFormSheet(FormSheet fs)
          Set a FormSheet in the SalesPoint's status display.
protected  void setStatusMenuSheet(MenuSheet ms)
          Set a MenuSheet in the SalesPoint's status display.
 void suspend()
          Suspend the SalesPoint.
 String toString()
          Return a String description of this SalesPoint: the name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_pCurProcess

protected SaleProcess m_pCurProcess
The process currently running on this SalesPoint, if any.
Constructor Detail

SalesPoint

public SalesPoint(String sName)
Create a new SalesPoint.
Parameters:
sName - the name of the SalesPoint.
Method Detail

getProcessLock

protected final Object getProcessLock()
Return the monitor synchronizing process access.
Override:
Never.

getName

public String getName()
Return the name of this SalesPoint.
Override:
Never.

canQuit

protected boolean canQuit(boolean fNoPersistence)
Check whether this SalesPoint can be closed. Unless the SalesPoint has been suspended before calling canQuit the result of this method may not be reliable.

By default, if a process runs on the SalesPoint its canQuit method is called. If no process is running, and fNoPersistence is true, onCanQuit() is called which opens a MsgForm to ask the user whether he/she really wants to close the SalesPoint. If fNoPersistence is false and no process is running on the SalesPoint, the default implementation always returns true.

This method is usually not called directly.

Override:
Sometimes.
See above for an description of the default implementation.
Parameters:
fNoPersistence - true if the call to canQuit resulted from an explicit call to quit() or from a call to Shop.shutdown (false). If fNoPersistence == false you can assume, the state of the SalesPoint will be made persistent before it is closed.
Hooks:
Change A SalesPoint's Quit Conditions

onCanQuit

protected boolean onCanQuit()
Hook method called to determine whether a SalesPoint with no process running on it can be closed by an explicit quit call. In this method you can assume that the state of the SalesPoint will not be saved and therefore will not be restoreable.
Override:
Sometimes.
The default implementation opens a MsgForm asking the user if they really want to close the SalesPoint.
Returns:
true if the SalesPoint can be closed, false otherwise.
Hooks:
Change A SalesPoint's Quit Conditions

quit

public void quit()
Close the SalesPoint.

First suspends the SalesPoint, then calls canQuit(boolean). If that returns false, quit will resume() the SalesPoint and return. Otherwise, it quits the current process, if any, and removes the SalesPoint from the Shop.

Override:
Never.

logSalesPointOpened

protected void logSalesPointOpened()
Hook method called when the SalesPoint is added to a Shop. You can write a log entry here.
Override:
Sometimes.
The default implementation does nothing.
Hooks:
Log Opening And Closing Of SalesPoints
See Also:
Shop.addSalesPoint(sale.SalesPoint), Log, LogEntry

logSalesPointClosed

protected void logSalesPointClosed()
Hook method called when the SalesPoint is removed from a Shop. You can write a log entry here.
Override:
Sometimes.
The default implementation does nothing.
Hooks:
Log Opening And Closing Of SalesPoints
See Also:
Shop.removeSalesPoint(sale.SalesPoint), Log, LogEntry

runProcess

public final void runProcess(SaleProcess p)
Start a process on this SalesPoint.

The process will run in the context of this SalesPoint, and with the DataBasket attached to this SalesPoint.

Although there can only be one process at a time running on this SalesPoint, no exception is thrown if a process already runs. Instead, the new process is silently ignored.

Override:
Never.
Parameters:
p - the process to be run.
Hooks:
Incorporate a process that needs user interaction

getCurrentProcess

public final SaleProcess getCurrentProcess()
Get the process currently running on this SalesPoint, if any.
Override:
Never.

suspend

public void suspend()
             throws InterruptedException
Suspend the SalesPoint.

If a process is running on the SalesPoint, it is suspended. The method will only return when the SalesPoint has been properly suspended.

Override:
Never.
Throws:
InterruptedException - if an interrupt occurred while waiting for the SalesPoint to be suspended.

resume

public void resume()
Resume the SalesPoint.

If a process is running on the SalesPoint, it is resumed.

Override:
Never.

attach

public User attach(User usr)
Attach a user to this SalesPoint.

The user attached to a SalesPoint can be accessed by processes running on the SalesPoint an can be used to determine capabilities etc.

Override:
Never.
Parameters:
usr - the user to be attached.
Returns:
the user that was previously attached to this SalesPoint, if any.

detachUser

public User detachUser()
Detach any user currently attached to this SalesPoint.
Override:
Never.
Returns:
the user that was previously attached to this SalesPoint, if any.

getUser

public User getUser()
Get the user currently attached to this SalesPoint.
Override:
Never.
Returns:
the user currently attached to this SalesPoint, if any.

attach

public DataBasket attach(DataBasket db)
Attach a DataBasket to this SalesPoint.
Override:
Never.
Parameters:
db - the DataBasket to be attached.
Returns:
the DataBasket that was previously attached to this SalesPoint, if any.
Hooks:
Specify a transactional context for a point of sale

detachBasket

public DataBasket detachBasket()
Detach any DataBasket currently attached to this SalesPoint.
Override:
Never.
Returns:
the DataBasket that was previously attached to this SalesPoint, if any.

getBasket

public DataBasket getBasket()
Get the DataBasket currently attached to this SalesPoint.
Override:
Never.
Returns:
the DataBasket currently attached to this SalesPoint, if any.

attachStatusDisplay

protected Display attachStatusDisplay(Display dStatus)
Attach a status display to the SalesPoint.

This display can be used to give status information about the SalesPoint. It can also be used to trigger background processes for the SalesPoint. It should not be used to trigger processes on the SalesPoint.

If the given display is not null, it must be useable.

Override:
Never.
Parameters:
dStatus - the new status display for this SalesPoint.
Returns:
the previous status display, if any.

detachStatusDisplay

protected Display detachStatusDisplay()
Detach the current status display.
Override:
Never.
Returns:
the previous status display, if any.

setStatusFormSheet

protected void setStatusFormSheet(FormSheet fs)
Set a FormSheet in the SalesPoint's status display.

Status display FormSheet's are always nonmodal, which is why this method returns immediately after setting the FormSheet and can never throw an InterruptedException.

Override:
Never.
Parameters:
fs - the FormSheet to be set.

setStatusMenuSheet

protected void setStatusMenuSheet(MenuSheet ms)
Set a MenuSheet in the SalesPoint's status display.
Override:
Never.
Parameters:
ms - the MenuSheet to be set.

getDefaultStatusMenuSheet

protected MenuSheet getDefaultStatusMenuSheet()
Get the default status MenuSheet for this SalesPoint.

Unless you specify differently through an explicit call to setStatusMenuSheet(sale.MenuSheet), the Framework will use this MenuSheet for the SalesPoint's status display.

Override:
Sometimes.
The default implementation returns null to indicate no MenuSheet.
Hooks:
Define new status MenuSheet for a point of sale
See Also:
attachStatusDisplay(sale.Display)

getDefaultStatusFormSheet

protected FormSheet getDefaultStatusFormSheet()
Get the default status FormSheet for this SalesPoint.

Unless you specify differently through an explicit call to setStatusFormSheet(sale.FormSheet), the Framework will use this FormSheet for the SalesPoint's status display.

Override:
Sometimes.
The default implementation returns an empty FormSheet.
Hooks:
Define new Status FormSheet for point of sale
See Also:
attachStatusDisplay(sale.Display)

attach

public Display attach(Display d)
Attach a new display to the SalesPoint.

Any Form- or MenuSheets displayed on the current display will be removed, and the SalesPoint's default sheets will be set on the new display.

Override:
Never.
Parameters:
d - the new display
Returns:
the previously attached display, if any.
See Also:
getDefaultFormSheet(), getDefaultMenuSheet()

detachDisplay

public Display detachDisplay()
Detach the current display.

Any Form- or MenuSheet on the current display will be removed before detaching the display.

Override:
Never.
Returns:
the detached display, if any.

getDisplay

public Display getDisplay()
Return the display of this SalesPoint.
Returns:
the display of this SalesPoint.

getDefaultFormSheet

protected FormSheet getDefaultFormSheet()
Get the default FormSheet for this SalesPoint.

The default FormSheet will be displayed whenever there is a current user (and, thus, a display), but no process is running and no other FormSheet is being displayed.

Override:
Always.
The default implementation returns a FormSheet that simply states the name of the SalesPoint.
Returns:
the default FormSheet, if any.
Hooks:
Define new FormSheet for point of sale

getDefaultMenuSheet

protected MenuSheet getDefaultMenuSheet()
Get the default MenuSheet for this SalesPoint.

The default MenuSheet will be displayed whenever there is a current user (and, thus, a display), but no process is running.

Override:
Always.
The default implementation returns null indicating no MenuSheet.
Returns:
the default MenuSheet, if any.
Hooks:
Define new MenuSheet for a point of sale

setFormSheet

public void setFormSheet(SaleProcess p,
                         FormSheet fs)
                  throws InterruptedException
Allow a process to set a FormSheet on the SalesPoint's current display.

The process launching the FormSheet as well as this SalesPoint will be attached to the FormSheet prior to displaying it. Thus, Actions triggered by the FormSheet will run in the correct context and will be able to access the process and the SalesPoint.

If the FormSheet requests that the Framework wait for it being closed, setFormSheet() will block until the FormSheet was closed or an interrupt occured.

Override:
Never.
Specified by:
setFormSheet in interface ProcessContext
Parameters:
p - the process that wants to display the FormSheet.
fs - the FormSheet to be displayed.
Throws:
InterruptedException - if an interrupt occurred while waiting for the FormSheet to be closed.
See Also:
Action, FormSheet.waitResponse()

setSalesPointFrameBounds

public void setSalesPointFrameBounds(Rectangle r)
Sets the Framebounds of the SalesPoints assoziated Display (JDisplayFrame).

Example:

sp.setSalesPointFrameBounds (new Rectangle (10,10,200,200)); This moves the SalesPointFrame to Position (10,10) with a size of (200,200).

Override:
Sometimes.

getSalesPointFrameBounds

public Rectangle getSalesPointFrameBounds()
Returns the Framebounds of the SalesPoints assoziated Display(JDisplayFrame).
Override:
Sometimes.

popUpFormSheet

public void popUpFormSheet(SaleProcess p,
                           FormSheet fs)
                    throws InterruptedException
Allow a process to pop up a FormSheet on the SalesPoint's current display.

The process launching the FormSheet as well as this SalesPoint will be attached to the FormSheet prior to displaying it. Thus, Actions triggered by the FormSheet will run in the correct context and will be able to access the process and the SalesPoint.

If the FormSheet requests that the Framework wait for it being closed, popUpFormSheet will block until the FormSheet was closed or an interrupt occured.

Override:
Never.
Specified by:
popUpFormSheet in interface ProcessContext
Parameters:
p - the process that wants to display the FormSheet.
fs - the FormSheet to be displayed.
Throws:
InterruptedException - if an interrupt occurred while waiting for the FormSheet to be closed.
See Also:
Action, FormSheet.waitResponse()

setMenuSheet

public void setMenuSheet(SaleProcess p,
                         MenuSheet ms)
Allow a process to set a MenuSheet on the SalesPoint's current display.

The process setting the MenuSheet as well as this SalesPoint will be attached to the MenuSheet prior to displaying it. Thus, Actions triggered by the MenuSheet will run in the correct context and will be able to access the process and the SalesPoint.

Override:
Never.
Specified by:
setMenuSheet in interface ProcessContext
Parameters:
p - the process that wants to display the MenuSheet.
ms - the MenuSheet to be displayed.
See Also:
Action

hasUseableDisplay

public boolean hasUseableDisplay(SaleProcess p)
True, if the SalesPoint currently has a display and this display is useable.
Override:
Never.
Specified by:
hasUseableDisplay in interface ProcessContext
Parameters:
p - the process querying, unused.
See Also:
Display.isUseableDisplay()

log

public void log(SaleProcess p,
                Loggable la)
         throws IOException
Log the given Loggable.

The given loggable object will be logged into the global log file unless you override this method.

Override:
Sometimes.
Specified by:
log in interface ProcessContext
Parameters:
p - the SalesProcess demanding logging, unused.
la - the object to be logged.
Throws:
IOException - if an error occurs while trying to write the log data.

getCurrentUser

public final User getCurrentUser(SaleProcess p)
Get the current user for the given process. This is the user, if any, previously attached with the attach(User) method.
Override:
Never.
Specified by:
getCurrentUser in interface ProcessContext
Parameters:
p - the process querying, unused.
Returns:
the current user
See Also:
getUser()

getStock

public Stock getStock(String sName)
Return a Stock for a given name.
Override:
Sometimes.
Specified by:
getStock in interface ProcessContext
Parameters:
sName - the name of the Stock.

getCatalog

public Catalog getCatalog(String sName)
Return a Catalog for a given name.
Override:
Sometimes.
Specified by:
getCatalog in interface ProcessContext
Parameters:
sName - the name of the Catalog.

processStarted

public void processStarted(SaleProcess p)
Notification that a process started on a SalesPoint.

This will remove all SalesPoint owned Form- and MenuSheets from the display, as to make room for the process' sheets.

Override:
Never.
Specified by:
processStarted in interface ProcessContext
Parameters:
p - the process that was just launched.

processFinished

public void processFinished(SaleProcess p)
Notification that a process finished running on this SalesPoint.

This will restore the SalesPoint's default sheets.

Override:
Never.
Specified by:
processFinished in interface ProcessContext

formSheetSet

public void formSheetSet(FormSheetEvent e)
Dummy interface to conform by the FormSheetListener interface.
Override:
Never.
Specified by:
formSheetSet in interface FormSheetListener

formSheetRemoved

public void formSheetRemoved(FormSheetEvent e)
Implemented to make sure there always is a FormSheet.
Override:
Never.
Specified by:
formSheetRemoved in interface FormSheetListener

toString

public String toString()
Return a String description of this SalesPoint: the name.
Override:
Sometimes.
Overrides:
toString in class Object

SalesPoint Framework v3.0