OSB_LIB::Associate Class Reference

Inheritance diagram for OSB_LIB::Associate:

Inheritance graph
[legend]
Collaboration diagram for OSB_LIB::Associate:

Collaboration graph
[legend]
List of all members.

Detailed Description

Abstract base class for OSB operator's business partners.

The class is a mere collection of data, it currently does not support any business logic.

Remarks:
Copy constructor and assignment by compiler.

Definition at line 73 of file associate.h.

Public Types

Public Member Functions

Read access to data members
Modify data members
Status changes:
Address list maintenance
Children Id list maintenance

Static Public Member Functions

Protected Attributes

Private Member Functions

Locking and object version maintenance
Apply status requests and changes:
Maintain list of contract ids.

Static Private Member Functions

Friends


Member Typedef Documentation

typedef std::auto_ptr<Associate> OSB_LIB::Associate::AutoPtr

Short-cut for an auto pointer.

For details see quality manual, implementation patterns: Virtual copy construction.

Reimplemented in OSB_LIB::Customer.

Definition at line 119 of file associate.h.

typedef std::map<Oid, Type> OSB_LIB::Associate::ChildrenList

STL container for associate children ids.

Definition at line 107 of file associate.h.

typedef Id<Contract> OSB_LIB::Associate::ContractId

Short-hand for a contract object id.

Definition at line 109 of file associate.h.

typedef std::set<ContractId> OSB_LIB::Associate::ContractIds

STL container for contracts of the associate.

Definition at line 111 of file associate.h.

typedef Id<Associate> OSB_LIB::Associate::Oid

Object id of Associate, database link.

Definition at line 105 of file associate.h.


Member Enumeration Documentation

enum OSB_LIB::Associate::Type

Supported types of associates.

The values must correspond with the database ASSOCIATE.ASSOCIATE_TYPE.

For each concrete associate class a new type must be defined and AssociateFactory::create needs to support the new value accordingly.

Enumerator:
atUnknown  Unknown associate type.
atCustomer  OSB customer, this is the end user (database: 'c').

Definition at line 97 of file associate.h.


Constructor & Destructor Documentation

OSB_LIB::Associate::Associate ( const Oid id  )  [inline]

Constructor with object id.

Definition at line 123 of file associate.h.

virtual OSB_LIB::Associate::~Associate (  )  [virtual]

Virtual destructor: unregister from A&C list.


Member Function Documentation

const std::string & OSB_LIB::Associate::accountNo (  )  const [inline]

Definition at line 930 of file associate.h.

References accountNo_.

bool OSB_LIB::Associate::addAddress ( OSB_DB::Session session,
const Address addr 
)

Add an address to the database.

Add a new address entry to the database. Also add it to the address list.

Parameters:
session Database session to use.
addr Address to be added.
Returns:
True if it is successful, false for already exist.
Exceptions:
OsbException 
  • the object has been changed or deleted
  • as specified by the gateway class.

void OSB_LIB::Associate::addChild ( OSB_DB::Session session,
Associate child 
)

Add a child for this associate.

Parameters:
session Database session to use.
child Associate to add as child.
Exceptions:
OsbException from lock(const OSB_DB::Session&, bool) const.
OsbException if the update() of child fails.
OsbException the associate is deactivated.
The function does not create the child in database, it only sets the parent-child relationship between two existing associates.

The operation is not allowed when the associate is deactivated.

Todo:
Possibly the activation status of the child changes! void reparent(Associate*) might be better.

bool OSB_LIB::Associate::addContract ( const OSB_DB::Session session,
const ContractId coId 
) [private]

Add a contract for this associate.

Parameters:
session Database session to use.
coId Object id of the contract to add.
Returns:
true if successful, else false.
Exceptions:
OsbException if the associate is deactivated.
OsbException from lock(const OSB_DB::Session&, bool) const.

Address* OSB_LIB::Associate::address ( AddressType  at  ) 

Find address for given type from address list.

Parameters:
at Type of address.
Returns:
Pointer to address if found,
else 0.

const AddressList & OSB_LIB::Associate::addressList (  )  const [inline]

Definition at line 970 of file associate.h.

References addressList_.

void OSB_LIB::Associate::addressListErase ( AddressType  type  )  [private]

Erase an address with given type from address list.

Parameters:
type Address type.

bool OSB_LIB::Associate::applyChange ( const OSB_DB::Session session,
const StatusChange change,
OsbErrors errors,
bool  noWait 
) [private]

Apply a change of the effective status to contract and children.

Parameters:
session Database session to use.
change Status change to process, it contains the old and new effective status.
errors Gets errors and warnings.
noWait Don't wait for database locks?
Needed to lock the contract and children.
Returns:
true if no error occurred during processing, else false.
Note:
Strictly private.

bool OSB_LIB::Associate::changeStatus ( const OSB_DB::Session session,
StatusChange change,
OsbErrors errors,
bool  noWait 
) [private]

Change the effective status of the associate.

Parameters:
session Database session to use.
change Copy of the status change to process, it contains the max. allowed effective status.
errors Gets errors and warnings.
noWait Don't wait for database locks?
Needed to lock the contract and children.
Returns:
true if no error occurred during processing, else false.
Note:
Even if the function returns true, errors still may contain warnings.

Called only by RequestHandler or Associate.

const Associate::ChildrenList & OSB_LIB::Associate::childrenList (  )  const [inline]

Definition at line 975 of file associate.h.

References childrenList_.

AutoPtr OSB_LIB::Associate::clone (  )  const

Virtual copy construction.

For details see quality manual, implementation patterns.

Reimplemented in OSB_LIB::Customer.

virtual Associate* OSB_LIB::Associate::clone_ (  )  const [private, pure virtual]

Internal virtual copy constructor.

For details see quality manual, implementation patterns.

Implemented in OSB_LIB::Customer.

const Associate::ContractIds & OSB_LIB::Associate::contractIds (  )  const [inline]

Definition at line 980 of file associate.h.

References contractIds_.

bool OSB_LIB::Associate::delAddress ( OSB_DB::Session session,
AddressType  type,
OsbErrors errors 
)

Delete an address with given address type from database.

This will delete an address only with this type or delete a type from a shared address.
The address list will be updated if an address was deleted.
Address of type 'atBilling' can not be deleted if any contract with this owner is active.

Parameters:
session Database session to use.
type Address type to be deleted.
errors Container for detected errors.
Returns:
True if it is successful.
Exceptions:
OsbException 
  • the object has been changed or deleted
  • type not exists
  • as specified by the gateway class.
    OsbError
  • billing type in any active contract

void OSB_LIB::Associate::delChild ( OSB_DB::Session session,
Associate child 
)

Delete a child for this associate.

Parameters:
session Database session to use.
child Associate to remove as child.
Exceptions:
OsbException from lock(const OSB_DB::Session&, bool) const.
OsbException if the update() of child fails.
Does not delete the child from database, it only unlinks the parent-child relationship between two associates:
the parent id and level of the child are unset.

Todo:
Possibly the activation status of the child changes! void reparent(Associate*) might be better.

void OSB_LIB::Associate::delContract ( const OSB_DB::Session session,
const ContractId coId 
) [private]

Delete a contract for this associate.

Parameters:
session Database session to use.
coId Contract to be deleted.
Exceptions:
OsbException from lock(const OSB_DB::Session&, bool) const.

const Status & OSB_LIB::Associate::effStatus (  )  const [inline]

Definition at line 935 of file associate.h.

References effStatus_.

const DateTime & OSB_LIB::Associate::effStatusDate (  )  const [inline]

Definition at line 940 of file associate.h.

References effStatusDate_.

const Address* OSB_LIB::Associate::findAddress ( AddressType  at  )  const

Find address for given type from address list.

Parameters:
at Type of address.
Returns:
Pointer to address if found,
else 0.

const Address& OSB_LIB::Associate::getAddress ( AddressType  at  )  const

Find address for given type from address list.

Parameters:
at Type of address.
Exceptions:
OsbException 
  • object not found.
Returns:
Ref to the found address.

void OSB_LIB::Associate::getChildEffStatus ( const OSB_DB::Session session,
StatusChanges dest 
) [private]

Get effective status changes of dependants.

Parameters:
session Database session to use.
dest List of status changes to populate.
Note:
dest only get the effective status of the child associates and contracts.
It will not provide the information to whom an status belongs.

static void OSB_LIB::Associate::handleObjectStatus ( ObjectStatus  os,
const Associate::Oid id 
) [static, private]

Evalute the object status of an associate.

Parameters:
os Object status to evaluate.
id The id of the associate for which os is valid.
Exceptions:
ObjectDeleted 
ObjectModified 
ObjectBusy if noWait is true and the associate is locked by another database session.

void OSB_LIB::Associate::incObjVs ( const OSB_DB::Session session  )  [private]

Increment the object version by 1.

Parameters:
session Database session to use.
Exceptions:
OsbException (internal error) if the update of the object version fails in the database.
The function should be called only after a successful call to lock().

Remarks:
The object version has to be changed whenever there was a change in Associate itself, Address, or its children.

bool OSB_LIB::Associate::insert ( const OSB_DB::Session session  )  [private]

Insert an associate to the database.

Parameters:
session Database session to use.
Returns:
True if the associate was inserted into the database.
Exceptions:
OsbException 
  • as specified by the gateway class.

template<typename A>
const A * OSB_LIB::Associate::isa ( const A *&  ptr  )  const [inline]

Downcasting: see template<typename A> A* isa(A*&).

Definition at line 889 of file associate.h.

template<typename A>
A * OSB_LIB::Associate::isa ( A *&  ptr  )  [inline]

Downcast to a derived class.

The function uses dynamic_cast<A*> to downcast an object of Associate to an object of a derived class.

          ptr = dynamic_cast<A*>(this);
          return ptr;

An usage example is given below:

          void foo(const Associate& ass)
          {
              ...
              Customer* pCus;
              if (0 != ass.isa(pCus)) {
                  // work with pCus
              }
          }

Parameters:
ptr Pointer to cast to. It gets the result of the downcast. It's value will be 0 if the cast fails.
Returns:
The argument pointer `ptr' after the downcast.

Definition at line 882 of file associate.h.

unsigned int OSB_LIB::Associate::levelId (  )  const [inline]

Definition at line 910 of file associate.h.

References levelId_.

bool OSB_LIB::Associate::linkAddressType ( OSB_DB::Session session,
AddressType  type,
AddressType  newType 
)

Link a new type to the existing address.

This will duplicate the address with different type. That is the two or more types will share the same address.
If this type already exists in database, it will

Parameters:
session Database session to use.
type The exist type.
newType The new type to add.
Returns:
True if it is successful, false for already exist.
Exceptions:
OsbException 
  • the object has been changed or deleted
  • type not exists
  • as specified by the gateway class.

void OSB_LIB::Associate::lock ( const OSB_DB::Session session,
bool  noWait 
) const [private]

Lock an associate in the database.

Parameters:
session Database session to use.
noWait Don't wait for database locks?
Exceptions:
OsbException from handleObjectStatus().

static void OSB_LIB::Associate::lock ( const OSB_DB::Session session,
const Associate::Oid id,
bool  noWait 
) [static, private]

Lock an associate in the database.

Parameters:
session Database session to use.
id The object id of the associate to lock.
noWait Don't wait for database locks?
Exceptions:
OsbException from handleObjectStatus(), (ObjectModified is not applicable).

void OSB_LIB::Associate::lockChildren ( const OSB_DB::Session session,
bool  noWait 
) [private]

Lock all dependants of an associate in the database.

Parameters:
session Database session to use.
noWait Don't wait for database locks?
Exceptions:
OsbException if locking of a child assoicate or contract fails.

const std::string & OSB_LIB::Associate::name (  )  const [inline]

Definition at line 900 of file associate.h.

References name_.

long OSB_LIB::Associate::objVs (  )  const [inline]

Definition at line 955 of file associate.h.

References objVs_.

const Associate::Oid & OSB_LIB::Associate::oid (  )  const [inline]

Definition at line 895 of file associate.h.

References oid_.

const Associate::Oid & OSB_LIB::Associate::parentId (  )  const [inline]

Definition at line 905 of file associate.h.

References parentId_.

const Status & OSB_LIB::Associate::prefStatus (  )  const [inline]

Definition at line 945 of file associate.h.

References prefStatus_.

const DateTime & OSB_LIB::Associate::prefStatusDate (  )  const [inline]

Definition at line 950 of file associate.h.

References prefStatusDate_.

const Account & OSB_LIB::Associate::purchaseLedger (  )  const [inline]

Definition at line 925 of file associate.h.

References purchaseLedger_.

bool OSB_LIB::Associate::read ( const OSB_DB::Session session  ) 

Read the associate from the database.

Parameters:
session Database session to use.
Returns:
true if the associate was found and read from the database, else false.

void OSB_LIB::Associate::readStatusChanges ( const OSB_DB::Session session,
const Period period 
)

Get status changes for a period of time.

The function reads the status changes for an associate itself in a time period.

Parameters:
session Database session to use.
period Time period covered by the status requests,
the upper boundary is not included.

void OSB_LIB::Associate::readStatusRequests ( const OSB_DB::Session session,
const Period period 
)

Get status requests for a period of time.

The function reads the status requests for an associate itself in a time period.

Parameters:
session Database session to use.
period Time period covered by the status requests,
the upper boundary is not included.

bool OSB_LIB::Associate::remove ( const OSB_DB::Session session  )  [private]

Delete an associate from the database.

Delete an associate, this only can be done when the status is svCreated.

Parameters:
session Database session to use.
Returns:
true if the associate was deleted from the database, else false.
Exceptions:
OsbException if the effective status is not created.
OsbException if contracts are assigned to the associate.

bool OSB_LIB::Associate::requestStatus ( const OSB_DB::Session session,
StatusRequest request,
OsbErrors errors,
bool  noWait 
)

Set the preferred status of the associate.

Parameters:
session Database session to use.
request Preferred status to set, see below.
errors Get warnings and errors during processing.
noWait Don't wait for database locks?
Returns:
true if the request is accepted, else false.
Exceptions:
OsbException from lock(const OSB_DB::Session&, bool) const.
When calling the function, status must have the requested status set; if the status date is not set, system time is used.
If successful the request id, the requested date/time and the entry timestamp will be set.

const Account & OSB_LIB::Associate::salesLedger (  )  const [inline]

Definition at line 920 of file associate.h.

References salesLedger_.

void OSB_LIB::Associate::setAccountNo ( const std::string &  accountNo  ) 

void OSB_LIB::Associate::setName ( const std::string &  name  ) 

OsbError OSB_LIB::Associate::setPrefStatus ( const OSB_DB::Session session,
const StatusRequest request 
) [private]

Set the preferred status of the associate.

Parameters:
session Database session to use.
request Status request that triggered the change of the preferred status.
Returns:
The first encountered error.
Note:
Called by RequestHandler only.

void OSB_LIB::Associate::setPurchaseLedger ( const Account pl  ) 

void OSB_LIB::Associate::setSalesLedger ( const Account sl  ) 

void OSB_LIB::Associate::setTaxKey ( const TaxKey::Oid tkId  ) 

const StatusChanges & OSB_LIB::Associate::statusChanges (  )  const [inline]

Get the status changes.

The list is meaningful only after having called readStatusChanges().

Definition at line 960 of file associate.h.

References chngs_.

const StatusRequests & OSB_LIB::Associate::statusRequests (  )  const [inline]

Get the status requests.

The list is meaningful only after having called readStatusRequests().

Definition at line 965 of file associate.h.

References reqs_.

const TaxKey::Oid & OSB_LIB::Associate::taxkey (  )  const [inline]

Definition at line 915 of file associate.h.

References taxkey_.

static char OSB_LIB::Associate::toChar ( Type  at  )  [static]

Convert an associate type into a char.

Parameters:
at Value to convert.
Returns:
Type corresponding associate item type. Its value is atUnknown if `at' is not supported.

static Type OSB_LIB::Associate::type ( char  at  )  [static]

Convert a char to associate type.

Parameters:
at Associate type to convert.
Returns:
The corresponsing char value. Its value is (char)atUnknown if `at' is not supported.

virtual Type OSB_LIB::Associate::typeId (  )  const [pure virtual]

The type of the associate.

The function returns the type of the associate. It is needed for only one reason: Corba clients must provide a configuration window that depends on the actual type.

No appropriate design can be provided: Unless on-line clients use the real associate type through-out the whole live cycle of an object, there must be a way to determine the actual type of a associate. No matter how clever we make our design, for on-line clients there will always be one step where they need to determine a associate type in a switch-like statement. For this step I personally perfer to work with an enumeration type (and compiler warnings) rather than relying on dynamic casts (where errors can be detected only during run-time).

Remarks:
Derived classes declare the function private.

Implemented in OSB_LIB::Customer.

bool OSB_LIB::Associate::unlinkAddressType ( OSB_DB::Session session,
AddressType  type 
)

Unlink an address type from the shared address.

Unlink a type from a shared address. Create a new address entry only with this type instead. Nothing done if this type has no other shared type.
Add the new created address to the address list and commit the session if successful.

Parameters:
session Database session to use.
type The type to be unlink.
Returns:
True if it is successful.
Exceptions:
OsbException 
  • the object has been changed or deleted
  • type not exists
  • as specified by the gateway class.

bool OSB_LIB::Associate::updAddress ( OSB_DB::Session session,
const Address addr 
)

Update an address for this associate.

Parameters:
session Database session to use.
addr Address to be updated.
Returns:
True if it is successful.
Exceptions:
OsbException 
  • the object has been changed or deleted
  • as specified by the gateway class.

void OSB_LIB::Associate::update ( OSB_DB::Session session  ) 

Update an associate to the database.

Parameters:
session Database session to use.
Exceptions:
OsbException from lock(const OSB_DB::Session&, bool) const if the update fails.


Friends And Related Function Documentation

friend class AnCList [friend]

Provide access to database operations and contract list maintenance.

Definition at line 79 of file associate.h.

friend class OSB_DB::AssociateGw [friend]

Definition at line 74 of file associate.h.

friend class RequestHandler [friend]

Provide access to functions to change the preferred or effective status.

Definition at line 84 of file associate.h.


Member Data Documentation

std::string OSB_LIB::Associate::accountNo_ [protected]

Visible ID of the Associate.

Definition at line 778 of file associate.h.

Referenced by accountNo().

AddressList OSB_LIB::Associate::addressList_ [protected]

list of all addresses

Definition at line 796 of file associate.h.

Referenced by addressList().

ChildrenList OSB_LIB::Associate::childrenList_ [protected]

list of next level associates

Definition at line 798 of file associate.h.

Referenced by childrenList().

StatusChanges OSB_LIB::Associate::chngs_ [protected]

List of status changes.

Definition at line 792 of file associate.h.

Referenced by statusChanges().

ContractIds OSB_LIB::Associate::contractIds_ [protected]

list of object id of contracts

Definition at line 800 of file associate.h.

Referenced by contractIds().

Status OSB_LIB::Associate::effStatus_ [protected]

the "currently" effective status

Definition at line 782 of file associate.h.

Referenced by effStatus().

DateTime OSB_LIB::Associate::effStatusDate_ [protected]

date when effective status was set

Definition at line 784 of file associate.h.

Referenced by effStatusDate().

unsigned int OSB_LIB::Associate::levelId_ [protected]

The level of the associate inside a hierarchical structure.

It is 0 for associates without parents (top-level).

Definition at line 772 of file associate.h.

Referenced by levelId().

std::string OSB_LIB::Associate::name_ [protected]

name of the Associate

Definition at line 763 of file associate.h.

Referenced by name().

long OSB_LIB::Associate::objVs_ [protected]

Object version.

Definition at line 790 of file associate.h.

Referenced by objVs().

Oid OSB_LIB::Associate::oid_ [protected]

unique id: database link

Definition at line 761 of file associate.h.

Referenced by oid().

AnCList* OSB_LIB::Associate::pAncList_ [protected]

Pointer to the manageing AnCList.

This is needed in applyStatus() only and can be remove once requestStatus() does no more call the status handler.

Definition at line 807 of file associate.h.

Oid OSB_LIB::Associate::parentId_ [protected]

id of parent

Definition at line 765 of file associate.h.

Referenced by parentId().

Status OSB_LIB::Associate::prefStatus_ [protected]

the perferred status of the associate

Definition at line 786 of file associate.h.

Referenced by prefStatus().

DateTime OSB_LIB::Associate::prefStatusDate_ [protected]

date when preferred status was requested

Definition at line 788 of file associate.h.

Referenced by prefStatusDate().

Account OSB_LIB::Associate::purchaseLedger_ [protected]

Purchase ledger for suppliers.

Definition at line 776 of file associate.h.

Referenced by purchaseLedger().

StatusRequests OSB_LIB::Associate::reqs_ [protected]

List of status requests.

Definition at line 794 of file associate.h.

Referenced by statusRequests().

Account OSB_LIB::Associate::salesLedger_ [protected]

Sales ledger for customers.

Definition at line 774 of file associate.h.

Referenced by salesLedger().

TaxKey::Oid OSB_LIB::Associate::taxkey_ [protected]

taxkey of the associate

Definition at line 780 of file associate.h.

Referenced by taxkey().


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