| NAME | SYNOPSIS | DESCRIPTION | IMPLEMENTATION | NOTES | WARNINGS | SEE ALSO | AUTHORS |
ServiceDescription - Each instance of this object provides a static description of each service.
| ServiceDescription Base: Entity | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Namespace Procedure Constructors
Standard Public Interface
Public InterfaceNone |
This procedure resides in this file to load the namespace into memory. It must be called before any namespace variable is accessed or any of the standard database interface functions are needed. It should be called when the application is being initialized.
namespace eval ServiceDescription {
variable this
variable attr
variable oid
variable serviceName
variable serviceType
variable description
#Insure the base class is initialized
#Insure the referenced class is initialized
#Insure the contained classes are initialized
#The directives
#This is a derived class, so a join is needed with the base class
#The from clause specifies the tables and aliases to be read in order from base to derived.
#table specifies the derived table name and the alias
#class specifies the namespace
#where specifies the join constraint
#hierarchy specifies the order of tables to be written from base to derived.
set this(from) {ServiceDescription sd}
set this(table) "ServiceDescription sd"
set this(class) ServiceDescription
set this(containedClass) {}
set this(container) {}
set this(where) ""
set this(hierarchy) [list $this(class)]
#Import the 'refers to' class attributes
#Import the base class attributes
lappend this(attrs) oid
set oid(type) Integer
set oid(key) Primary
set oid(column) {sd.oid}
set oid(table) $this(class)
set oid(defWidth) 9
set oid(label) { (0-9); 9 characters max}
set oid(default) {}
set attr(oid) [array get oid]
.
lappend this(attrs) serviceName
set serviceName(type) Text
set serviceName(column) {sd.serviceName}
set serviceName(table) $this(class)
set serviceName(label) {(a,A - z,Z); 20 characters max}
set serviceName(defWidth) 20
set serviceName(default) {}
set attr(serviceName) [array get serviceName]
lappend this(attrs) serviceType
set serviceType(type) EnumText
set serviceType(column) {sd.serviceType}
set serviceType(enum) { food {F: Food} postal {P: Postal} cleaning {C: Cleaning}\
banking {B: Banking} retail {R: Retail} conference {N: Conference \
maintenance {M: Maintenance}}
set serviceType(table) $this(class)
set serviceType(label) {}
set serviceType(defWidth) [Entity::EnumMax $serviceType(enum)]
set serviceType(default) {M: Maintenance}
set attr(serviceType) [array get serviceType]
lappend this(attrs) description
set description(type) Text
set description(column) {sd.description}
set description(table) $this(class)
set description(label) {(a,A - z,Z); 255 characters max}
set description(defWidth) 255
set description(default) {}
set attr(description) [array get description]
}
#Create the standard member functions, but only once
EntityCreate $ServiceDescription::this(class)
EntityQuery $ServiceDescription::this(class)
EntityNext $ServiceDescription::this(class)
EntityInsert $ServiceDescription::this(class)
EntityUpdate $ServiceDescription::this(class)
EntityDelete $ServiceDescription::this(class)
EntityRefresh $ServiceDescription::this(class)
EntityGetAttribute $ServiceDescription::this(class)
EntityRetrieve $ServiceDescription::this(class)
EntityContainedList $ServiceDescription::this(class)
EntityArrayCopy $ServiceDescription::this(class)
EntityValue $ServiceDescription::this(class)
EntityInsertUpdate $ServiceDescription::this(class)
EntityMdtRetrieve $ServiceDescription::this(class)
EntityRetrieveObjBy $ServiceDescription::this(class)
EntityRetrieveOidBy $ServiceDescription::this(class)
EntityUpdateWhere $ServiceDescription::this(class)
EntityDeleteWhere $ServiceDescription::this(class)
EntityContainer $ServiceDescription::this(class)
EntityCount $ServiceDescription::this(class)
EntityGetListOf $ServiceDescription::this(class)
proc ServiceDescriptionInit { {db DbObject} {connection 1} } {
set ServiceDescription::this(DbObject) $db
set ServiceDescription::this(inst) $connection
return
}
# STANDARD SETUP FOR TCL EXAMPLE SCRIPTS
# Setup a unique name for this test instance
set PROCNAME ServiceDescriptionTest
set SUFFIX [join [list [exec hostname] [pid] ] {.}]
set TESTPROC [format "%s.%s" $PROCNAME $SUFFIX]
#Setup a database connection
global handle scriptName
set scriptName ServiceDescription
if {[lsearch [array names env] DBUSER] >= 0} {
set dbuser $env(DBUSER)
} else {
set dbuser tle
}
if {[lsearch [array names env] DSQUERY] >= 0} {
set dbserver $env(DSQUERY)
} else {
set dbserver SYBdevgdn
}
if {[lsearch [array names env] DBPASS] >= 0} {
set dbpass $env(DBPASS)
} else {
set dbpass tle123
}
set handle [sybconnect $dbuser $dbpass $dbserver $scriptName]
puts "Making Database Connection"
DbObject::Connect tle tle123 SYBurkel
puts "Initializing the ServiceDescription Entity"
ServiceDescriptionInit
puts "Creating ServiceDescription objects a, b"
ServiceDescription::Create a
ServiceDescription::Create b
DbObject::Begin
puts "Testing insert of object a"
if [catch {set oid [ServiceDescription::Insert a]} result] {
puts $result
DbObject::Rollback
exit
}
puts "Insert ok, oid: $oid"
puts "Testing Query"
if [catch {ServiceDescription::Query b "s.managedObjOid = $oid"} result] {
puts $result
DbOject::Rollback
exit
}
puts "Retrieving and loading object b"
if [catch {set rtn [ServiceDescription::Next b]} result] {
puts $result
DbOject::Rollback
exit
}
puts "Refreshing object a"
if [catch {set rtn [ServiceDescription::Refresh a]} result] {
puts $result
DbOject::Rollback
exit
}
if {$rtn} {
puts "a & b comparison"
if {[string compare [array get a] [array get b]] != 0} {
puts "Failed comparison"
DbObject::Rollback
exit
}
}
puts "Testing Update"
set a(serviceName) "Software Services"
if [catch {ServiceDescription::Update a} result] {
puts $result
DbOject::Rollback
exit
}
puts "Refreshing object b"
if [catch {set rtn [ServiceDescription::Refresh b]} result] {
puts $result
DbOject::Rollback
exit
}
if {$rtn} {
puts "a & b comparison"
if {[string compare [array get a] [array get b]] != 0} {
puts "Failed comparison"
DbObject::Rollback
exit
}
}
puts "Deleting the object"
if [catch {ServiceDescription::Delete b} result] {
puts $result
DbObject::Rollback
exit
}
DbObject::Commit
puts "ServiceDescription test Passed!"
DbObject::Close
by Timothy L. Eshelman & Susan Pringle