" *****************************************************************************************************
*
*  type.txt
*
*   This examples shows how to define types in a Model
*
*
******************************************************************************************************"


| aModel aTextDisplay aType attributesDict|
aTextDisplay := TextWindow  windowLabeled: 'LPC Brokers - creating a type'
                           frame: (0 @ 0 corner: 500 @ 500).
aTextDisplay cr. 
 
 
"Define our type"
aType := LPCObjectType 
    createNewFromDbName: #Course 
            table: (Array with:'Course' with: nil with: nil)
            fields: #( (nil nil 'Course' 'COURSE' '1') 
                           (nil nil 'Course' 'CREDIT' '3')
                           (nil nil 'Course' 'HOURS' '4')
                           (nil nil 'Course' 'DESCRIPTION' '1'))
            keys: #( (nil nil nil 'Course') ).
  
" let's redefine our model and add this type to the model
  We will need it for the next example"
 aModel := LPCModel newName: #LpcSample.
aModel addType: aType.

"Displaying a Collection of  types defined in our model"
aTextDisplay nextPutAll: '*** Models defined in ', aModel modelName , ' ***' ; cr.
aModel types do: [ :each | aTextDisplay nextPutAll: each typeName ; cr ].


 
