The class is a mere collection of data, it currently does not support any business logic.
Definition at line 73 of file associate.h.
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 |
typedef Id<Contract> OSB_LIB::Associate::ContractId |
typedef std::set<ContractId> OSB_LIB::Associate::ContractIds |
typedef Id<Associate> OSB_LIB::Associate::Oid |
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.
atUnknown | Unknown associate type. |
atCustomer | OSB customer, this is the end user (database: 'c'). |
Definition at line 97 of file associate.h.
OSB_LIB::Associate::Associate | ( | const Oid & | id | ) | [inline] |
virtual OSB_LIB::Associate::~Associate | ( | ) | [virtual] |
Virtual destructor: unregister from A&C list.
const std::string & OSB_LIB::Associate::accountNo | ( | ) | const [inline] |
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.
session | Database session to use. | |
addr | Address to be added. |
OsbException |
|
void OSB_LIB::Associate::addChild | ( | OSB_DB::Session & | session, | |
Associate & | child | |||
) |
Add a child for this associate.
session | Database session to use. | |
child | Associate to add as child. |
OsbException | from lock(const OSB_DB::Session&, bool) const. | |
OsbException | if the update() of child fails. | |
OsbException | the associate is deactivated. |
The operation is not allowed when the associate is deactivated.
bool OSB_LIB::Associate::addContract | ( | const OSB_DB::Session & | session, | |
const ContractId & | coId | |||
) | [private] |
Add a contract for this associate.
session | Database session to use. | |
coId | Object id of the contract to add. |
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.
at | Type of address. |
const AddressList & OSB_LIB::Associate::addressList | ( | ) | const [inline] |
void OSB_LIB::Associate::addressListErase | ( | AddressType | type | ) | [private] |
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.
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. |
bool OSB_LIB::Associate::changeStatus | ( | const OSB_DB::Session & | session, | |
StatusChange & | change, | |||
OsbErrors & | errors, | |||
bool | noWait | |||
) | [private] |
Change the effective status of the associate.
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. |
Called only by RequestHandler or Associate.
const Associate::ChildrenList & OSB_LIB::Associate::childrenList | ( | ) | const [inline] |
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] |
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.
session | Database session to use. | |
type | Address type to be deleted. | |
errors | Container for detected errors. |
OsbException |
|
void OSB_LIB::Associate::delChild | ( | OSB_DB::Session & | session, | |
Associate & | child | |||
) |
Delete a child for this associate.
session | Database session to use. | |
child | Associate to remove as child. |
OsbException | from lock(const OSB_DB::Session&, bool) const. | |
OsbException | if the update() of child fails. |
void OSB_LIB::Associate::delContract | ( | const OSB_DB::Session & | session, | |
const ContractId & | coId | |||
) | [private] |
Delete a contract for this associate.
session | Database session to use. | |
coId | Contract to be deleted. |
OsbException | from lock(const OSB_DB::Session&, bool) const. |
const Status & OSB_LIB::Associate::effStatus | ( | ) | const [inline] |
const DateTime & OSB_LIB::Associate::effStatusDate | ( | ) | const [inline] |
const Address* OSB_LIB::Associate::findAddress | ( | AddressType | at | ) | const |
Find address for given type from address list.
at | Type of address. |
const Address& OSB_LIB::Associate::getAddress | ( | AddressType | at | ) | const |
Find address for given type from address list.
at | Type of address. |
OsbException |
|
void OSB_LIB::Associate::getChildEffStatus | ( | const OSB_DB::Session & | session, | |
StatusChanges & | dest | |||
) | [private] |
Get effective status changes of dependants.
session | Database session to use. | |
dest | List of status changes to populate. |
static void OSB_LIB::Associate::handleObjectStatus | ( | ObjectStatus | os, | |
const Associate::Oid & | id | |||
) | [static, private] |
Evalute the object status of an associate.
os | Object status to evaluate. | |
id | The id of the associate for which os is valid. |
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.
session | Database session to use. |
OsbException | (internal error) if the update of the object version fails in the database. |
bool OSB_LIB::Associate::insert | ( | const OSB_DB::Session & | session | ) | [private] |
Insert an associate to the database.
session | Database session to use. |
OsbException |
|
const A * OSB_LIB::Associate::isa | ( | const A *& | ptr | ) | const [inline] |
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 } }
ptr | Pointer to cast to. It gets the result of the downcast. It's value will be 0 if the cast fails. |
Definition at line 882 of file associate.h.
unsigned int OSB_LIB::Associate::levelId | ( | ) | const [inline] |
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
session | Database session to use. | |
type | The exist type. | |
newType | The new type to add. |
OsbException |
|
void OSB_LIB::Associate::lock | ( | const OSB_DB::Session & | session, | |
bool | noWait | |||
) | const [private] |
Lock an associate in the database.
session | Database session to use. | |
noWait | Don't wait for database locks? |
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.
session | Database session to use. | |
id | The object id of the associate to lock. | |
noWait | Don't wait for database locks? |
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.
session | Database session to use. | |
noWait | Don't wait for database locks? |
OsbException | if locking of a child assoicate or contract fails. |
const std::string & OSB_LIB::Associate::name | ( | ) | const [inline] |
long OSB_LIB::Associate::objVs | ( | ) | const [inline] |
const Associate::Oid & OSB_LIB::Associate::oid | ( | ) | const [inline] |
const Associate::Oid & OSB_LIB::Associate::parentId | ( | ) | const [inline] |
const Status & OSB_LIB::Associate::prefStatus | ( | ) | const [inline] |
const DateTime & OSB_LIB::Associate::prefStatusDate | ( | ) | const [inline] |
const Account & OSB_LIB::Associate::purchaseLedger | ( | ) | const [inline] |
bool OSB_LIB::Associate::read | ( | const OSB_DB::Session & | session | ) |
Read the associate from the database.
session | Database session to use. |
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.
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.
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.
session | Database session to use. |
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.
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? |
OsbException | from lock(const OSB_DB::Session&, bool) const. |
const Account & OSB_LIB::Associate::salesLedger | ( | ) | const [inline] |
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.
session | Database session to use. | |
request | Status request that triggered the change of the preferred status. |
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] |
static char OSB_LIB::Associate::toChar | ( | Type | at | ) | [static] |
Convert an associate type into a char.
at | Value to convert. |
static Type OSB_LIB::Associate::type | ( | char | at | ) | [static] |
Convert a char to associate type.
at | Associate type to convert. |
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).
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.
session | Database session to use. | |
type | The type to be unlink. |
OsbException |
|
bool OSB_LIB::Associate::updAddress | ( | OSB_DB::Session & | session, | |
const Address & | addr | |||
) |
Update an address for this associate.
session | Database session to use. | |
addr | Address to be updated. |
OsbException |
|
void OSB_LIB::Associate::update | ( | OSB_DB::Session & | session | ) |
Update an associate to the database.
session | Database session to use. |
OsbException | from lock(const OSB_DB::Session&, bool) const if the update fails. |
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.
std::string OSB_LIB::Associate::accountNo_ [protected] |
AddressList OSB_LIB::Associate::addressList_ [protected] |
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] |
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] |
long OSB_LIB::Associate::objVs_ [protected] |
Oid OSB_LIB::Associate::oid_ [protected] |
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] |
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] |