com.ivata.mask.web.demo.catalog
Class Catalog

java.lang.Object
  extended bycom.ivata.mask.web.demo.catalog.Catalog
All Implemented Interfaces:
com.ivata.mask.persistence.PersistenceManager

public final class Catalog
extends java.lang.Object
implements com.ivata.mask.persistence.PersistenceManager

This is the main class of the demo. It represents a catalog of products.

Since:
ivata masks 0.1 (2004-05-09)
Version:
$Revision: 1.13 $
Author:
Colin MacLeod colin.macleod@ivata.com

Field Summary
static int INVALID_ID
          Unique id for invalid objects.
 
Method Summary
 com.ivata.mask.valueobject.ValueObject add(com.ivata.mask.persistence.PersistenceSession session, com.ivata.mask.valueobject.ValueObject valueObject)
           Add a new object to be persisted.
 void amend(com.ivata.mask.persistence.PersistenceSession session, com.ivata.mask.valueobject.ValueObject valueObject)
           Persist changes to an existing object.
 java.util.List findAll(com.ivata.mask.persistence.PersistenceSession session, java.lang.Class classParam)
          Retrieve all instances of a particular class.
 com.ivata.mask.valueobject.ValueObject findByPrimaryKey(com.ivata.mask.persistence.PersistenceSession session, java.lang.Class classParam, java.io.Serializable key)
          Retrieve a single instance of a particular class.
static Catalog getInstance()
           Get the sole instance of this class.
 com.ivata.mask.MaskFactory getMaskFactory()
           Get the mask factory used throughout this application.
 com.ivata.mask.persistence.right.PersistenceRights getPersistenceRights()
          Just returns an instance of the default rights implementation.
 com.ivata.mask.persistence.PersistenceSession openSession()
           Open a catalog session.
 com.ivata.mask.persistence.PersistenceSession openSession(java.lang.Object systemSession)
          You can't use a system session in this simple demo.
 void remove(com.ivata.mask.persistence.PersistenceSession session, java.lang.Class classParam, java.io.Serializable key)
           Remove a value object from the system.
 void reset()
           Reset the catalog to its initial state.
 void setMaskFactory(com.ivata.mask.MaskFactory factory)
           Set the mask factory used throughout this application.
protected  void setPropertyValues(com.ivata.mask.valueobject.ValueObject from, com.ivata.mask.valueobject.ValueObject to)
           Override to set all property values from one value object to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID_ID

public static final int INVALID_ID
Unique id for invalid objects.

See Also:
Constant Field Values
Method Detail

getInstance

public static Catalog getInstance()

Get the sole instance of this class.

For the demo, this is a singleton. It's better to use dependency injection or service locator patterns, in real life.

Returns:
only instance of this class.

add

public com.ivata.mask.valueobject.ValueObject add(com.ivata.mask.persistence.PersistenceSession session,
                                                  com.ivata.mask.valueobject.ValueObject valueObject)
                                           throws com.ivata.mask.persistence.PersistenceException

Add a new object to be persisted.

Specified by:
add in interface com.ivata.mask.persistence.PersistenceManager
Parameters:
session - open persistence session, used to store the object.
valueObject - value object to be persisted.
Returns:
new value object with id set appropriately.
Throws:
com.ivata.mask.persistence.PersistenceException - thrown by the underlying persistence mechanism if the object cannot be saved for any reason.
See Also:
PersistenceManager.add(com.ivata.mask.persistence.PersistenceSession, com.ivata.mask.valueobject.ValueObject)

amend

public void amend(com.ivata.mask.persistence.PersistenceSession session,
                  com.ivata.mask.valueobject.ValueObject valueObject)
           throws com.ivata.mask.persistence.PersistenceException

Persist changes to an existing object.

Specified by:
amend in interface com.ivata.mask.persistence.PersistenceManager
Parameters:
session - open persistence session, used to store the changes to the object.
valueObject - value object to be persisted.
Throws:
com.ivata.mask.persistence.PersistenceException - thrown by the underlying persistence mechanism if the object cannot be saved for any reason.
See Also:
PersistenceManager.amend(com.ivata.mask.persistence.PersistenceSession, com.ivata.mask.valueobject.ValueObject)

findAll

public java.util.List findAll(com.ivata.mask.persistence.PersistenceSession session,
                              java.lang.Class classParam)
Retrieve all instances of a particular class. This method is used in the list pages.

Specified by:
findAll in interface com.ivata.mask.persistence.PersistenceManager
Parameters:
session - open persistence session, used to fetch the objects.
classParam - class of objects to be retrieved. Must be a subclass of ValueObject.
Returns:
List containing instances of the requested class.
See Also:
com.ivata.mask.PersistenceManager#locateByBaseClass

findByPrimaryKey

public com.ivata.mask.valueobject.ValueObject findByPrimaryKey(com.ivata.mask.persistence.PersistenceSession session,
                                                               java.lang.Class classParam,
                                                               java.io.Serializable key)
                                                        throws com.ivata.mask.persistence.PersistenceException
Retrieve a single instance of a particular class. This method is used in the input/display pages.

Specified by:
findByPrimaryKey in interface com.ivata.mask.persistence.PersistenceManager
Parameters:
session - open persistence session, used to fetch the object.
classParam - class of object to be retrieved. Must be a subclass of ValueObject.
key - unique identifier of the object to retrieve.
Returns:
instance of the requested class which matches the identifier key.
Throws:
com.ivata.mask.persistence.PersistenceException - thrown by the underlying persistence mechanism if the object cannot be retrieved for any reason.
See Also:
PersistenceManager.findByPrimaryKey(com.ivata.mask.persistence.PersistenceSession, java.lang.Class, java.io.Serializable)

getMaskFactory

public com.ivata.mask.MaskFactory getMaskFactory()

Get the mask factory used throughout this application. This is used to create and retrieve input/list masks.

Returns:
mask factory used throughout this application.

getPersistenceRights

public com.ivata.mask.persistence.right.PersistenceRights getPersistenceRights()
Just returns an instance of the default rights implementation. This lets you do everything :-)

Specified by:
getPersistenceRights in interface com.ivata.mask.persistence.PersistenceManager
Returns:
Instance of DefaultPersistenceRights.

openSession

public com.ivata.mask.persistence.PersistenceSession openSession()
                                                          throws com.ivata.mask.persistence.PersistenceException

Open a catalog session.

Specified by:
openSession in interface com.ivata.mask.persistence.PersistenceManager
Throws:
com.ivata.mask.persistence.PersistenceException
See Also:
PersistenceManager.openSession()

openSession

public com.ivata.mask.persistence.PersistenceSession openSession(java.lang.Object systemSession)
                                                          throws com.ivata.mask.persistence.PersistenceException
You can't use a system session in this simple demo. This method throws an exception of class UnsupportedOperationException.

Specified by:
openSession in interface com.ivata.mask.persistence.PersistenceManager
Parameters:
systemSession -
Returns:
Throws:
com.ivata.mask.persistence.PersistenceException
See Also:
PersistenceManager.openSession()

remove

public void remove(com.ivata.mask.persistence.PersistenceSession session,
                   java.lang.Class classParam,
                   java.io.Serializable key)
            throws com.ivata.mask.persistence.PersistenceException

Remove a value object from the system.

Specified by:
remove in interface com.ivata.mask.persistence.PersistenceManager
Parameters:
session - open persistence session, used to remove the object.
classParam - class of object to be retrieved. Must be a subclass of ValueObject.
key - unique identifier of the object to retrieve.
Throws:
com.ivata.mask.persistence.PersistenceException - thrown by the underlying persistence mechanism if the object cannot be removed for any reason.
See Also:
PersistenceManager.remove(com.ivata.mask.persistence.PersistenceSession, java.lang.Class, java.io.Serializable)

reset

public void reset()

Reset the catalog to its initial state.


setMaskFactory

public void setMaskFactory(com.ivata.mask.MaskFactory factory)

Set the mask factory used throughout this application.

Parameters:
factory - mask factory used throughout this application.

setPropertyValues

protected void setPropertyValues(com.ivata.mask.valueobject.ValueObject from,
                                 com.ivata.mask.valueobject.ValueObject to)

Override to set all property values from one value object to another.

Parameters:
from - value object to take values from.
to - value object to set values in.


Copyright © 2001-2005 ivata limited. All Rights Reserved.