" *****************************************************************************************************
*
*  updobj.txt
*
*   This examples shows how to updateTypes in the database
*
*
******************************************************************************************************"


| aModel aTextDisplay anOrb aCourse  courseType oodb|
aTextDisplay := TextWindow  windowLabeled: 'LPC Brokers - creating new objects'
                           frame: (0 @ 0 corner: 500 @ 500).
aTextDisplay cr. 
 
aModel := LPCModel getName: #LpcSample.
courseType :=aModel typeNamed: #Course.


anOrb := LPCObjectRequestBroker new.
anOrb driverConnectWindow: aTextDisplay.

"set the model's orb it will be used by all type defined in the model
unless overidden"
aModel orb: anOrb.

"set autoCommit to be true"
anOrb autoCommit: true.

"retrieve our course"
aCourse := anOrb lookUpForKeyValue: #('ODB')  withType: courseType.


"let's change some attributes"
aCourse hours: aCourse hours - 1.
aCourse description: 'Still in progress'.

" store it in the database"
aCourse saveToDatabase.

"let's make sure it is stored"
oodb := anOrb lookUpForKeyValue: #('ODB')  withType: courseType.

aTextDisplay
      nextPutAll: 'Course: ', oodb course asString; cr
    ; nextPutAll: 'Hours: ', oodb hours asString; cr
    ; nextPutAll: 'Credit: ', oodb credit asString; cr
    ; nextPutAll: 'Description: ' , oodb description asString; cr .


anOrb disconnect.
 
