BuildingService (3BuildingService)

NAME SYNOPSIS DESCRIPTION IMPLEMENTATION NOTES WARNINGS SEE ALSO AUTHORS

NAME

BuildingService - This object is derived from Service and holds the specific information for all BuildingServices

SYNOPSIS

BuildingService
Base: Service
oid
dt
buildingLocation

Namespace Procedure Constructors

BuildingServiceInit  {}  

Standard Public Interface

BuildingService::Create { objRef {selectList} }
BuildingService::ArrayCopy { objRef {selectList} } : objList
BuildingService::Query { objRef {where} {order} }
BuildingService::Next { objRef } : 1(Success), 0(Failure)
BuildingService::Insert { objRef } : oid
BuildingService::Update { objRef }
BuildingService::Delete { objRef }
BuildingService::Refresh { objRef } : 1(Success), 0(Failure)
BuildingService::Retrieve { oid objRef {selectList} } : 1(Success), 0(Failure)
BuildingService::GetAttribute { {attribute} {property} {enumTagList} } : results - See documentation
BuildingService::ContainedList { containerOid {selectList} } : objList
BuildingService::Value { oid attr {value} } : value
BuildingService::InsertUpdate { objRef {attr value} ... } : oid
BuildingService::MdtRetrieve { oid objRef } : 1(Success), 0(Failure)
BuildingService::RetrieveObjBy { {attr value} ... } : objList
BuildingService::RetrieveOidBy { {attr value} ... } : oidList
BuildingService::UpdateWhere { objref {attr value} ... } : oidList
BuildingService::DeleteWhere { {attr value} ... }
BuildingService::Count { attr {attr value} ... } : count
BuildingService::Container { oid objRef } : 1(Success), 0(failure)
BuildingService::GetListOf { attr { attr value} ... } : valueList

Public Interface

BuildingService::Insert { objref } : oid

None

 

DESCRIPTION

BuildingServiceInit

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.

Inputs: None
Outputs: None
Returns: None

BuildingService::Insert {objref} : oid

This procedure is redefined to call Service::Insert.

Inputs:
objref - The object instance array to insert.
Outputs: None
Returns:
The newly inserted object id.

IMPLEMENTATION

  
namespace eval BuildingService {
   variable this
   variable attr

   variable oid
   variable dt
   variable buildingLocation
   

       #Insure the base class is initialized
   ServiceInit

       #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) {ManagedObj m, Service s, ServiceDescription sd, buildingService bs}
   set this(table) "BuildingService bs"
   set this(class) BuildingService
   set this(containedClass) {}
   set this(container) ManagedObj
   set this(where) "m.oid = s.managedObjOid and s.serviceDescriptionOid = sd.oid and bs.serviceOid = s.managedObjOid"
   set this(hierarchy) [list ManagedObj Service $this(class)]
         #Import the 'refers to' class attributes
   

         #Import the base class attributes
   array set attr [Service::GetAttribute]
   lappend this(attrs) oid
   set oid(type) Integer
   set oid(key) Foreign
   set oid(column) {bs.serviceOid}
   set oid(table) $this(class)
   set oid(defWidth) 9
   set oid(label) {}
   set oid(default) {}
   set attr(oid) [array get oid]
   .
   lappend this(attrs) dt
   set dt(type) Text
   set dt(column) {bs.dt}
   set dt(table) $this(class)
   set dt(label) {(a,A - z,Z); 24 characters max}
   set dt(defWidth) 24
   set dt(default) {}
   set attr(dt) [array get dt] 

   lappend this(attrs) buildingLocation
   set buildingLocation(type) Text
   set buildingLocation(table) $this(class)
   set buildingLocation(label) {(a,A - z,Z); 50 characters max}
   set buildingLocation(column) {bs.buildingLocation}
   set buildingLocation(defWidth) 50
   set buildingLocation(default) {} 
   set attr(buildingLocation) [array get buildingLocation]
    
   set this(attrs) [union $this(attrs) $Service::this(attrs)]
   
}

#Create the standard member functions, but only once
EntityCreate $BuildingService::this(class)
EntityQuery $BuildingService::this(class)
EntityNext $BuildingService::this(class)

     #Redefine to use a virtual function
#EntityInsert $BuildingService::this(class)
ServiceInsert $BuildingService::this(class)

EntityUpdate $BuildingService::this(class)
EntityDelete $BuildingService::this(class)
EntityRefresh $BuildingService::this(class)
EntityGetAttribute $BuildingService::this(class)
EntityRetrieve $BuildingService::this(class)
EntityContainedList $BuildingService::this(class)
EntityArrayCopy $BuildingService::this(class)
EntityValue $BuildingService::this(class)
EntityInsertUpdate $BuildingService::this(class)
EntityMdtRetrieve $BuildingService::this(class)
EntityRetrieveObjBy $BuildingService::this(class)
EntityRetrieveOidBy $BuildingService::this(class)
EntityUpdateWhere $BuildingService::this(class)
EntityDeleteWhere $BuildingService::this(class)
EntityContainer $BuildingService::this(class)
EntityCount $BuildingService::this(class)
EntityGetListOf $BuildingService::this(class)

BuildingServiceInit

proc BuildingServiceInit { {db DbObject} {connection 1} } {
   set BuildingService::this(DbObject) $db
   set BuildingService::this(inst) $connection
   return
}

BuildingService::Insert {objref} : oid

proc BuildingService::Insert { objref } {
   upvar $objref obj
   variable this
   
   return [Service::Insert obj $this(class)]
}

EXAMPLES

#  STANDARD SETUP FOR TCL EXAMPLE SCRIPTS
#  Setup a unique name for this test instance

set PROCNAME BuildingServiceTest
set SUFFIX [join [list [exec hostname] [pid] ] {.}]
set TESTPROC [format "%s.%s" $PROCNAME $SUFFIX]
#Setup a database connection
global handle scriptName
set scriptName BuildingService
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
  }

puts "Making Database Connection"
DbObject::Connect tle tle123 SYBdevgdn

puts "Initializing the BuildingService Entity"
BuildingServiceInit

puts "Creating BuildingService objects a, b"
BuildingService::Create a
BuildingService::Create b

DbObject::Begin
puts "Testing insert of object a"
if [catch {set oid [BuildingService::Insert a]} result] {
     puts $result
     DbObject::Rollback
     exit
}
puts "Insert ok, oid: $oid"

puts "Testing Query"

if [catch {BuildingService::Query b "s.managedObjOid = $oid"} result] {
     puts $result
     DbOject::Rollback
     exit
}

puts "Retrieving and loading object b"

if [catch {set rtn [BuildingService::Next b]} result] {
     puts $result
     DbOject::Rollback
     exit
}

puts "Refreshing object a"

if [catch {set rtn [BuildingService::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(BuildingLocation) Middletown
if [catch {BuildingService::Update a} result] {
     puts $result
     DbOject::Rollback
     exit
}


puts "Refreshing object b"

if [catch {set rtn [BuildingService::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 {BuildingService::Delete b} result] {
     puts $result
     DbObject::Rollback
     exit
}
DbObject::Commit

puts "BuildingService test Passed!"

DbObject::Close

NOTES

WARNINGS

SEE ALSO

Entity.htm

TaskableEntity.htm

DbObject.htm

MO.htm


AUTHORS

by Timothy L. Eshelman