OSB_DB::PersProductGw Class Reference

List of all members.

Detailed Description

Database gateway for PERS_PRODCT, PERS_NODE and PERS_ITEM.

The class provide the database operations needed for the classes PersProduct, PersProductNode and all classes derived from PersProductItem.

Definition at line 66 of file persproduct-gw.h.

Public Member Functions

Private Member Functions

Support for database operations of PersProductItem
All functions supporting database operations do not commit or rollback transactions of the used Session. This is indicated by making the argument constant.

Status handling for pers. products:
Status handling for pers. products:

Friends


Constructor & Destructor Documentation

OSB_DB::PersProductGw::PersProductGw ( const PersProductGw  )  [private]

Do not allow copying: body not defined.

OSB_DB::PersProductGw::PersProductGw (  )  [inline]

Empty default constructor.

Remarks:
Needed because the copy constructor is declared private (and not implemented).

Destructor by compiler.

Definition at line 89 of file persproduct-gw.h.


Member Function Documentation

OSB_LIB::ObjectStatus OSB_DB::PersProductGw::checkObjVs ( const Session session,
const OSB_LIB::PersProduct pp 
) [private]

Check the object version of pers. product against the database.

Parameters:
session Database session to use.
pp Pers. product to verify.
Returns:
The object status for persProduct (busy is not applicable).

bool OSB_DB::PersProductGw::delPersNode ( const Session session,
const OSB_LIB::PersProductNode::Oid oid 
) [private]

Remove a PersProductNode from the table PERS_NODE.

The function removes a row from the table PERS_NODE for a personalized product node.

Parameters:
session Session to use.
oid Id of the pers. node to delete.
Returns:
true if the node was deleted, else false (node does not exist in the database).

bool OSB_DB::PersProductGw::delPersProduct ( const Session session,
const OSB_LIB::PersProduct pp 
) [private]

Delete a pers. product from the table PERS_PRODUCT.

Parameters:
session Database session to use.
pp PersProduct to delete.
Returns:
true if successful, else false.

bool OSB_DB::PersProductGw::delPersProductItem ( const Session session,
OSB_LIB::PersProductItem item 
) [private]

Delete a personalized product item.

The function deletes a pers. product item from PERS_ITEM.

The implementation relies on the foreign key constraints to prevent deletion of pers. product items with dependent rows.

Todo:
When and how do we check, if the item can be deleted? Exemple: Resource assignments must not be removed until the rating reproduction time has passed. Is this issue general, specific to some item types or both?
Parameters:
session Database session to use.
item Personalized product item to delete.
Returns:
True if the pers. item was deleted from the database, else false.

bool OSB_DB::PersProductGw::fetch ( const Session session,
OSB_LIB::PersProductItem item 
) [private]

Read a personalized product item.

(Re)reads a pers. product item from the database, using the item's object id as selection criteria. If a matching row is found, it sets the pers. item assign and deassign date.

Remarks:
The function does not read the columns PERS_PRODUCT_ID and PRODUCT_NODE_ID from PERS_ITEM and set the respective data members of the base class.
Parameters:
session Database session to use.
item Personalized product item to (re)read.
Returns:
True if the pers. item was read from the database, else false. In the latter case the base class members of `item' are not changed.

bool OSB_DB::PersProductGw::fetch ( const Session session,
OSB_LIB::PersProductNode pn 
)

Read a personalized product node by its object id.

Parameters:
session Database session to use.
pn Pers. product node to read:
its object id must be set.
Returns:
True if populated.
Exceptions:
OsbException in case of an illegal status.

bool OSB_DB::PersProductGw::fetch ( const Session session,
OSB_LIB::PersProduct pp 
)

Read a personalized product by its object id.

Parameters:
session Database session to use.
pp Pers. product to read:
its object id must be set.
Returns:
True if populated.
Exceptions:
OsbException in case of an illegal status.

long OSB_DB::PersProductGw::fetch ( const Session session,
OSB_LIB::Contract co 
)

Read personalized products of a contract.

Read all personalized product for a contract and add them to the destination list. (The list is cleared before adding the read pers. products.)

Parameters:
session Database session to use.
co Contract to read for.
Returns:
The number of personalized products read.
Exceptions:
OsbException in case of an illegal status.

long OSB_DB::PersProductGw::fetchItems ( const Session session,
OSB_LIB::PersProductNode persNode 
)

Read pers. product items for a pers. product node.

For each matching row in PERS_ITEM the function uses OSB_LIB::ProductItemFactory to create a pers. item of the appropriate type. After setting the base class data members, OSB_LIB::PersProductItem::read() is called to retrieve type specific data from the database.

Exception safety: Newly constructed pers. items are stored in a temporary list which is swapped with the list of `persNode' on regular return: In case of an exception, the original list of the pers. node remains unchanged.

Parameters:
session Database session to use: changes are neither commited not rolled back.
persNode Pers. product node to read for.
Returns:
The number of pers. product items read and stored in the destination list.
Exceptions:
OsbException 
  • if the type of the pers. item is not supported
  • type specific exceptions from read(...)
  • if type specific data can not be read.

long OSB_DB::PersProductGw::fetchNodes ( const Session session,
OSB_LIB::PersProduct pp 
)

Read personalized nodes for a personalized product.

Read all nodes for a personalized product and store in destination list.

The function uses a temporary list to store the pers. nodes read from the database and, on sucessful completion, swaps it with the list passed as argument.

Parameters:
session Database session to use.
pp Personalized product to read for.
Returns:
The number of personalized nodes read.
Exceptions:
OsbException in case of an illegal status.

OSB_LIB::Id<OSB_LIB::Contract> OSB_DB::PersProductGw::getContract ( const Session session,
const OSB_LIB::PersProduct::Oid ppId 
)

Get the contract id of a pers. product.

Parameters:
session Database session to use.
ppId Id of the pers. product to look-up.
Returns:
The contract id of the pers. product,
it is not set, if ppId is not found in the database.

bool OSB_DB::PersProductGw::incObjVs ( const Session session,
OSB_LIB::PersProduct pp 
)

Increment the object version of a pers. product.

This function will add 1 to the OBJ_VS in PERS_PRODUCT table.

Parameters:
session Database session to use.
pp Pers. product for which to increase the object version.
Returns:
true if the object version of pp was increased by 1, else false.

bool OSB_DB::PersProductGw::incPersProdObjVs ( const Session session,
const OSB_LIB::PersProduct::Oid ppId,
long objVs,
bool &  uptodate 
)

Add 1 to Object Version (OBJ_VS).

This function will add 1 to the OBJ_VS in PERS_PRODUCT database.

Remarks:
The object version has to be changed whenever there is a change in pers. product itself, PersProductNode, PersProductItem.
Parameters:
session Database session to use: changes are neither commited not rolled back.
ppId Pers. product oid to update.
objVs Old Object version. It will be updated to the new one.
uptodate Return true if the object version is uptodate before it gets updated in the database.
Returns:
Return true if no record gets updated.
Todo:
Remove, somehow this must go via the pers. product.

bool OSB_DB::PersProductGw::insPersNode ( const Session session,
OSB_LIB::PersProductNode persNode 
) [private]

Insert a PersProductNode into the table PERS_NODE.

The function inserts a row to the table PERS_NODE for a personalized product node.

Parameters:
session Session to use.
persNode PersProductNode to insert.
Returns:
Always true.
Exceptions:
OsbException if the node has an illegal preferred or effective status.

bool OSB_DB::PersProductGw::insPersProduct ( const Session session,
OSB_LIB::PersProduct pp 
) [private]

Insert a pers. product into the table PERS_PRODUCT.

Parameters:
session Session to use.
pp PersProduct to insert.
Returns:
True for success.

bool OSB_DB::PersProductGw::insPersProductItem ( const Session session,
OSB_LIB::PersProductItem item 
) [private]

Insert a personalized product item.

The function creates an entry in PERS_ITEM. It sets the new object id and the assigment date of `item'.

Parameters:
session Database session to use.
item Personalized product item to insert.
Returns:
True if the pers. item was inserted to the database, else false.
Exceptions:
OsbException in case of a database error.

OSB_LIB::ObjectStatus OSB_DB::PersProductGw::lock ( const Session session,
const OSB_LIB::PersProduct pp,
bool  noWait 
) [private]

Lock a pers. product entry in database.

Parameters:
session Database session.
pp Pers. product to lock.
noWait Don't wait for database locks?
Returns:
The object status for pp, busy is only applicable if noWait is true.

OSB_LIB::ObjectStatus OSB_DB::PersProductGw::lock ( const Session session,
const OSB_LIB::PersProduct::Oid ppId,
bool  noWait 
) [private]

Lock a pers. product entry in database.

Parameters:
session Database session.
ppId Object id of pers. product to be locked.
noWait Don't wait for database locks?
Returns:
The object status for ppId (modified is not applicable).

PersProductGw& OSB_DB::PersProductGw::operator= ( const PersProductGw  )  [private]

Do not allow assignment: body not defined.

bool OSB_DB::PersProductGw::setEffStatus ( const Session session,
const OSB_LIB::PersProductNode persNode 
) [private]

Save the effective status of a pers. node.

Parameters:
session Database session to use.
persNode Pers. node to process.
Returns:
true if the effective status was updated, else false.

bool OSB_DB::PersProductGw::setEffStatus ( const Session session,
const OSB_LIB::PersProduct pp 
) [private]

Save the effective status of a pers. product.

Parameters:
session Database session to use.
pp Pers. product to process.
Returns:
true if the effective status was updated, else false.

bool OSB_DB::PersProductGw::setPrefStatus ( const Session session,
const OSB_LIB::PersProductNode persNode 
) [private]

Save the prefer status of a pers. node.

Parameters:
session Database session to use.
persNode Pers. node to process.
Returns:
true if the preferred status was updated, else false.

bool OSB_DB::PersProductGw::setPrefStatus ( const Session session,
const OSB_LIB::PersProduct pp 
) [private]

Save the prefer status of a pers. product.

Parameters:
session Database session to use.
pp Pers. product to process.
Returns:
true if the preferred status was updated, else false.

void OSB_DB::PersProductGw::storeChange ( const Session session,
const OSB_LIB::PersProductNode::Oid ppnId,
OSB_LIB::StatusChange change 
) [private]

Store status change for a pers. product node.

Parameters:
session Database session to use.
ppnId Id of the pers. product node.
change Status change to store.

void OSB_DB::PersProductGw::storeChange ( const Session session,
const OSB_LIB::PersProduct::Oid ppId,
OSB_LIB::StatusChange change 
) [private]

Store status change for a pers. product.

Parameters:
session Database session to use.
ppId Id of the pers. product.
change Status change to store.

void OSB_DB::PersProductGw::storeRequest ( const Session session,
const OSB_LIB::PersProductNode::Oid ppnId,
OSB_LIB::StatusRequest status 
) [private]

Store status request for a pers. product node.

Parameters:
session Database session to use.
ppnId Id of the pers. product node.
status Status request to store.

void OSB_DB::PersProductGw::storeRequest ( const Session session,
const OSB_LIB::PersProduct::Oid ppId,
OSB_LIB::StatusRequest status 
) [private]

Store status request for a pers. product in the database.

Parameters:
session Database session to use.
ppId Id of the pers. product.
status Status request to store.

bool OSB_DB::PersProductGw::updPersProductItem ( const Session session,
OSB_LIB::PersProductItem item 
) [private]

Update a personalized product item.

The function updates a personalized product item, using the item's object id as selection criteria. Updated columns do not include PERS_PRODUCT_ID and PRODUCT_NODE_ID.

Parameters:
session Database session to use.
item Personalized product item to update.
Returns:
True if the pers. item was updated to the database, else false.
Remarks:
The function actually returns true, if at least one row in PERS_ITEM was updated. Of course, because of the table's primary key this should be one row only, but the function doesn't check for it.

bool OSB_DB::PersProductGw::updPpiAssignTs ( const Session session,
OSB_LIB::PersProductItem item,
const OSB_LIB::DateTime newTs 
) [private]

Change the assignment timestamp of a pers. product item to its node.

Parameters:
session Database session to use.
item Pers. product item for which to change the assignment timestamp.
newTs New date and time of the assignment.
Returns:
true if the pers. item exists in the database, else false.
Exceptions:
OsbException as specified by PersProductItem: if the new assignment period would overlap with other pers. items assigned to the pers. node.

bool OSB_DB::PersProductGw::updProductUser ( const Session session,
const OSB_LIB::PersProduct pp 
) [private]

Update product user of pers. product object.

The object version will also be updated.

Parameters:
session Database session.
pp Pers product object to be updated.
Returns:
true if updated successfully else false.


Friends And Related Function Documentation

friend class OSB_LIB::PersProduct [friend]

Definition at line 79 of file persproduct-gw.h.

friend class OSB_LIB::PersProductItem [friend]

Allow PersProductItem to call it's I/O supporting functions.

These are: fetch(..., PersProductItem&), insPersProductItem, updPersProductItem and delPersProductItem.

Definition at line 78 of file persproduct-gw.h.

friend class OSB_LIB::PersProductNode [friend]

Definition at line 80 of file persproduct-gw.h.


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:09:02 2006 for OSB Library by  doxygen 1.4.7