OSB_DB::ProductGw Class Reference

List of all members.

Detailed Description

Database gateway class for product related classes.

ProductGw is the database gateway class for Product, ProductItem and ProductNode.

Remarks:
Default, copy constructor, destructor and assignment by compiler.

Definition at line 74 of file product-gw.h.

Public Member Functions

Database operations of products
Database operations on product items
Database operations on product nodes
Database operations on product item type

Private Member Functions

Database operations on products.
Support for product item database operations
The following functions are used by OSB_LIB::ProductItem for the implementation of its database operation members. They must not be called from outside.

Friends


Member Function Documentation

bool OSB_DB::ProductGw::checkName ( const Session session,
const OSB_LIB::Product pd 
) [private]

Check that the product's name is not already used.

Compares the current product's name with the names of products in the database.

Parameters:
session Database session to use.
pd Pointer to the product.
Returns:
`true' if the name is NOT already used. `false' otherwise.

bool OSB_DB::ProductGw::checkObjVs ( const Session session,
const OSB_LIB::Product pd 
) [private]

Check that the object versions match.

Compares the current product's object version with the object version in the database.

Parameters:
session Database session to use.
pd Pointer to the product.
Returns:
`true' if the object versions are the same. `false' otherwise.

void OSB_DB::ProductGw::checkPiName ( const Session session,
const std::string &  name,
const OSB_LIB::Product::Oid pid 
)

Check that the name of product item is unique in one product.

Compares the current product item's name with the names of product items in the database.

Parameters:
session Oracle session.
name Product item name.
pid Object id of product this item belongs.
Exceptions:
OsbException name already exists in the product.

OSB_LIB::Product::Oid OSB_DB::ProductGw::creProduct ( const Session session,
OSB_LIB::Product pd 
)

Create a new product in the database.

Parameters:
session Database session to use.
pd Product to be created.
Exceptions:
OsbException 
  • name or description too long
  • unique database constraint violated.
Returns:
Oid of new product.
Remarks:
It is not the resposibility of this method to add the created product object to any container (e.g. to the product list of the product catalogue).

void OSB_DB::ProductGw::creProductNode ( const Session session,
const OSB_LIB::Product::Oid productId,
OSB_LIB::ProductNode productNode 
)

Create a product node in the database.

The function inserts a row into PRODUCT_NODE and sets the new object id of `node'.

Parameters:
session Database session to use.
productId Product id for this node belongs to.
productNode Product node to create.

void OSB_DB::ProductGw::delProduct ( const Session session,
const OSB_LIB::Product pd 
)

Delete a product from the database.

This includes the deletion of the database entry. The product object will not be deleted by this method. The owner has to do that.

Parameters:
session Database session to use.
pd Pointer to product to be deleted.
Remarks:
It is not the resposibility of this method to delete the product object from any container (e.g. from the product list of the product catalogue).

bool OSB_DB::ProductGw::delProductItem ( const Session session,
OSB_LIB::ProductItem item 
) [private]

Delete a product item from the database.

The function deletes a product item from the table PRODUCT_ITEM. The implementation relies on the foreign key constraints to prevent the deletion of product items that are still in use.

Remarks:
The function return false rather than throwing an exception if child records are found in the database.
Parameters:
session Database session to use.
item Product item to update.
Returns:
True if the product item was deleted in the database, else false.

void OSB_DB::ProductGw::delProductNode ( const Session session,
const OSB_LIB::ProductNode pNode 
)

Delete a ProductNode from the database.

This includes the deletion of the database entry. The ProductNode object will not be deleted by this method. The owner has to do that. The function is not responsible to delete the ProductNode object from any container! (esp from the master node list of the Product)

ToDo: Implement. ToDo: Obviously all children nodes of the Node to be deleted have to be deleted as well (respectively all grand children etc.) It has to be decided if the gateway does that or the using application!

Parameters:
session Database session to use.
pNode Product node to delete.

long OSB_DB::ProductGw::fetch ( const Session session,
OSB_LIB::ProductItemTypes dest 
)

Load all product item type.

This function will load all product item type from the database and store them in the product item type list.

Parameters:
session Oracle session.
dest Product item type list to populate.
Exceptions:
OsbException for unsupported product item types.
Returns:
Number of object populated.

long OSB_DB::ProductGw::fetch ( const Session session,
const OSB_LIB::Product::Oid pid,
OSB_LIB::ProductNodeParts pnList 
)

Read all product nodes of a product.

Read all product nodes of a product from the database and store them in the products nodes list.

Parameters:
session Database session to use.
pid Object id of product.
pnList Product node list to read for.
Returns:
Number of object populated.

bool OSB_DB::ProductGw::fetch ( const Session session,
OSB_LIB::ProductItem item 
) [private]

Read a product item from the database.

The function (re)reads an existing product item from the database. It populates data members if a matching row is found.

Parameters:
session Database session to use.
item Product item to read.
Returns:
True if the product item was read from the database, else false. In the latter case the `item' remains unchanged.

std::auto_ptr<OSB_LIB::ProductItem> OSB_DB::ProductGw::fetch ( const Session session,
const OSB_LIB::Id< OSB_LIB::ProductItem > &  oid 
)

Load a product item from the database.

Reads the product item from PRODUCT_ITEM. If a row with the matching object id is found, the function uses ProductItemFactory to allocate a new product item, populates the member of the base class and calls the virtual function OSB_LIB::ProductItem::read(...) to retrieve type specific information.

Parameters:
session Database session to use.
oid Object id of the product item to read.
Exceptions:
OsbException 
  • if the product item type is unknown
  • product item type specific exceptions.
Returns:
An auto pointer with the newly allocated product item. The content of the auto pointer will be 0 in the following situations:
  • the product item does not exist in the database
  • if item type specific data can not be read
  • in case of any exception.

bool OSB_DB::ProductGw::fetch ( const Session session,
OSB_LIB::Product pd 
)

Read a product.

Parameters:
session Database session to use.
pd Product to be populated.
Returns:
True if product was populated successfullly.

long OSB_DB::ProductGw::fetch ( const Session session,
OSB_LIB::Products pds 
)

Load all products into the argument STL containter.

Parameters:
session Database session to use.
pds Product list to be populated.
Returns:
Number of objects populated.

bool OSB_DB::ProductGw::insProductItem ( const Session session,
OSB_LIB::ProductItem item 
) [private]

Create a product item in the database.

The function inserts a row into PRODUCT_ITEM and sets the new object id of `item'.

Parameters:
session Database session to use.
item Product item to create.
Exceptions:
OsbExcpetion 
  • name too long
  • description too long
  • name not unique.

void OSB_DB::ProductGw::updProduct ( const Session session,
const OSB_LIB::Product pd 
)

Update contents of the database for a given product.

The database entry identified by this product's id already exists. The contents of the passed product object will not be changed by this method.

Parameters:
session Database session to use.
pd Product to be updated.
Exceptions:
OsbException 
  • name or description too long
  • name not unique.

bool OSB_DB::ProductGw::updProductItem ( const Session session,
OSB_LIB::ProductItem item 
) [private]

Update a product item.

Updates the base part members of a product item in the table PRODUCT_ITEM.

ToDo: On successful update the function should set the item's new object version (not supported yet).

Parameters:
session Database session to use.
item Product item to update.
Exceptions:
OsbException 
  • name or description too long
  • duplicate name or other unique constraint violation.
Returns:
True if the product item was found and updated in the database, else false.

void OSB_DB::ProductGw::updProductNode ( const Session session,
const OSB_LIB::Product::Oid prodId,
OSB_LIB::ProductNode pNode 
)

Update the contents of the database for a given ProductItem.

The database entry identified by this ProductItem's Id has already to exist. The contents of the passed ProductItem object will not be changed by this method. Note: the Product has to be passed, because there is no information within ProductNode to which Product it belongs to. Note: The update method is actually not necessary for the CORBA interface and is therefore not used.

Parameters:
session Database session to use.
prodId Product id for this node belongs to.
pNode Product node to update.


Friends And Related Function Documentation

friend class OSB_LIB::ProductItem [friend]

Allow OSB_LIB::ProductItem to call the members.

Definition at line 76 of file product-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