'From Squeak3.2 of 11 July 2002 [latest update: #4956] on 31 October 2002 at 9:29:05 pm'!
MimeConverter subclass: #Base64MimeConverter
	instanceVariableNames: 'data lineBreaks '
	classVariableNames: 'FromCharTable ToCharTable '
	poolDictionaries: ''
	category: 'Collections-Streams'!
Object subclass: #ConnectionManager
	instanceVariableNames: 'username password host port databaseName connectionPool '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
ConnectionManager class
	instanceVariableNames: 'current '!
Object subclass: #PackageManager
	instanceVariableNames: 'currentPackage packages '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PackageManager class
	instanceVariableNames: 'current '!
Object subclass: #PersistentObject
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentObject subclass: #ClassDefinitionRecord
	instanceVariableNames: 'packageRef classRef metaclassRef definitionOrder classRecord metaclassRecord package '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentObject subclass: #PersistentPKObject
	instanceVariableNames: 'primaryKey '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentPKObject subclass: #Blob
	instanceVariableNames: 'blobtype blobdata '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentPKObject subclass: #PersistentTraceObject
	instanceVariableNames: 'name trace timestamp username '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentTraceObject subclass: #MethodRecord
	instanceVariableNames: 'version classname metastring source sourcecodeId protocolName '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentTraceObject subclass: #PersistentTraceCommentObject
	instanceVariableNames: 'comment commentId '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentTraceCommentObject subclass: #ClassRecord
	instanceVariableNames: 'superclass definition definitionId environmentString '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentTraceCommentObject subclass: #DataElement
	instanceVariableNames: 'definitionId environmentString protocolName typeString definition '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
PersistentTraceCommentObject subclass: #Package
	instanceVariableNames: 'version binfile classDefinitions methodDefinitions changeSet properties propertiesId parcelId blessingLevel '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!
ConnectionManager subclass: #PgSqlConnectionManager
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'StORE-Core'!

!Object methodsFor: 'StORE' stamp: 'WFB 10/11/2002 02:41'!
sqlString
	^ self asString

! !


!Base64MimeConverter methodsFor: 'conversion' stamp: 'WFB 10/11/2002 11:10'!
mimeEncode
	"Convert from data to 6 bit characters."
	| phase1 phase2 raw nib lineLength |
	phase1 _ phase2 _ false.
	lineLength _ 0.
	[dataStream atEnd]
		whileFalse: [self lineBreaks ifTrue: [lineLength >= 70
				ifTrue: [mimeStream cr.
					lineLength _ 0]].
			data _ raw _ dataStream next asInteger.
			nib _ (data bitAnd: 252)
						bitShift: -2.
			mimeStream
				nextPut: (ToCharTable at: nib + 1).
			(raw _ dataStream next)
				ifNil: [raw _ 0.
					phase1 _ true].
			data _ ((data bitAnd: 3)
						bitShift: 8)
						+ raw asInteger.
			nib _ (data bitAnd: 1008)
						bitShift: -4.
			mimeStream
				nextPut: (ToCharTable at: nib + 1).
			(raw _ dataStream next)
				ifNil: [raw _ 0.
					phase2 _ true].
			data _ ((data bitAnd: 15)
						bitShift: 8)
						+ raw asInteger.
			nib _ (data bitAnd: 4032)
						bitShift: -6.
			mimeStream
				nextPut: (ToCharTable at: nib + 1).
			nib _ data bitAnd: 63.
			mimeStream
				nextPut: (ToCharTable at: nib + 1).
			lineLength _ lineLength + 4].
	phase1
		ifTrue: [mimeStream skip: -2;
				 nextPut: $=;
				 nextPut: $=.
			^ mimeStream].
	phase2
		ifTrue: [mimeStream skip: -1;
				 nextPut: $=.
			^ mimeStream]! !

!Base64MimeConverter methodsFor: 'accessing' stamp: 'WFB 10/11/2002 11:11'!
lineBreaks
	^(lineBreaks = false) not! !

!Base64MimeConverter methodsFor: 'accessing' stamp: 'WFB 10/11/2002 11:11'!
lineBreaks: anObject
	lineBreaks := anObject! !


!ChangeSet methodsFor: 'StORE in/out' stamp: 'WFB 10/11/2002 00:45'!
storeOutChangesFor: class on: package 
	"Write out all the method changes for this class."
	| changes |
	changes _ 
	(self methodChangesAtClass: class name).
	changes isEmpty
		ifFalse: [package storeOutChangedMessages: changes forClass: class]! !

!ChangeSet methodsFor: 'StORE in/out' stamp: 'WFB 10/11/2002 18:14'!
storeOutClassDefinition: class on: package 
	(self atClass: class includes: #rename)
		ifTrue: [package
				renameClass: (self oldNameFor: class)
				to: class name].
	(self atClass: class includes: #change)
		ifTrue: [package changeClass: class].
	(self atClass: class includes: #add)
		ifTrue: [package addClass: class].
	(self atClass: class includes: #comment)
		ifTrue: [package addClassComment: class]! !

!ChangeSet methodsFor: 'StORE in/out' stamp: 'WFB 10/11/2002 00:52'!
storeOutOn: package 
	"Write out all the changes the receiver knows about"
	| classList |
	package changeSet = nil ifTrue: [package changeSet: self].
	package changeSet = self
		ifFalse: [^ self error: 'This package does not belong to this changeSet'].
	classList _ ChangeSet superclassOrder: self changedClasses asOrderedCollection.
	"First put out rename, max classDef and comment changes."
	classList
		do: [:aClass | self storeOutClassDefinition: aClass on: package].
	"Then put out all the method changes"
	classList
		do: [:aClass | self storeOutChangesFor: aClass on: package].
	"Finally put out removals, final class defs and reorganization if any"
	classList
		reverseDo: [:aClass | self storeOutPSFor: aClass on: package].
	self classRemoves asSortedCollection
		do: [:aClassName | package removeClass: aClassName]! !

!ChangeSet methodsFor: 'StORE in/out' stamp: 'WFB 10/10/2002 22:59'!
storeOutPSFor: class on: package 
	"Write out removals and initialization for this class."
	| dict changeType classRecord |
	classRecord _ changeRecords
				at: class name
				ifAbsent: [^ self].
	dict _ classRecord methodChangeTypes.
	dict keysSortedSafely
		do: [:key | 
			changeType _ dict at: key.
			(#(#remove #addedThenRemoved ) includes: changeType)
				ifTrue: [package removeSelector: key storeString forClass: class]].
! !


!Class methodsFor: 'StORE' stamp: 'WFB 10/10/2002 23:35'!
fullName
	^ self namespace,'.',self name! !

!Class methodsFor: 'StORE' stamp: 'WFB 10/11/2002 18:07'!
namespace
	"Very crude way to get some sort of VW compatible namespaces"
	| kpkg |
	kpkg _ self category upTo: $-.
	kpkg = 'Kernel'
		ifTrue: [^'Core'].
	kpkg = 'Collections'
		ifTrue: [^'Core'].
	kpkg = 'Graphics'
		ifTrue: [^'UI'].
	kpkg = 'System'
		ifTrue: [^'Kernel'].
	kpkg = 'Network'
		ifTrue: [^'OS'].
	^ 'Smalltalk'! !


!Base64MimeConverter class methodsFor: 'as yet unclassified' stamp: 'WFB 10/11/2002 11:13'!
mimeNoLinebreakEncode: aStream 
	"Return a ReadWriteStream of characters. The data of aStream is encoded 
	as 65 innocuous characters. (See class comment). 3 bytes in aStream 
	goes to 4 bytes in output."
	| me |
	aStream position: 0.
	me _ self new dataStream: aStream.
	me lineBreaks: false.
	me
		mimeStream: (ReadWriteStream
				on: (String new: aStream size + 20 * 4 // 3)).
	me mimeEncode.
	me mimeStream position: 0.
	^ me mimeStream! !


!ConnectionManager methodsFor: 'private' stamp: 'WFB 10/7/2002 22:27'!
release
	connectionPool isNil ifFalse: [connectionPool copy
		do: [:elem | self terminateConnection: elem]. connectionPool := OrderedCollection new]!
]style[(7 2 14 44 6 2 4 22 4 43)f1b,f1,f1cmagenta;,f1,f1cred;,f1,f1cmagenta;,f1,f1cblue;i,f1! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:24'!
closeConnection: aConnection 
	connectionPool add: aConnection! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:23'!
createNewConnection
	connectionPool add: (self retrConnection)! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:23'!
getConnection
	connectionPool isEmpty ifTrue: [self createNewConnection].
	^connectionPool removeFirst! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/11/2002 01:53'!
getResultOfQuery: aQuery 
	self sessionDo: [:session |
	^ self getResultOfQuery: aQuery inSession: session]! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/11/2002 01:49'!
getResultOfQuery: aQuery inSession: session
	| resultSet |
	resultSet _ session execute: aQuery.
	resultSet errorResponse isNil
		ifFalse: [self error: resultSet errorResponse value].
	^ resultSet rows
		collect: [:row | row data copy]! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:20'!
initialize
	connectionPool := OrderedCollection new! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:21'!
retrConnection
	self subclassResponsibility! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/11/2002 01:52'!
sessionDo: aBlock 
	| session |
	[session _ self getConnection.
	aBlock value: session]
		ensure: [self closeConnection: session]! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:26'!
terminateConnection: aConnection 
	connectionPool remove: aConnection! !

!ConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:12'!
username: anUsername password: aPassword host: aHost port: aPort databaseName: aDatabaseName
 username := anUsername.
 password := aPassword.
 host := aHost.
	 port := aPort.
 databaseName := aDatabaseName
! !

!ConnectionManager methodsFor: 'accessing' stamp: 'WFB 10/11/2002 02:01'!
username
	^username! !

!ConnectionManager methodsFor: 'transactions' stamp: 'WFB 10/11/2002 02:35'!
beginTransactionInSession: session 
	self getResultOfQuery: 'BEGIN TRANSACTION' inSession: session ! !

!ConnectionManager methodsFor: 'transactions' stamp: 'WFB 10/11/2002 02:36'!
commitTransactionInSession: session 
	self getResultOfQuery: 'COMMIT' inSession: session ! !

!ConnectionManager methodsFor: 'transactions' stamp: 'WFB 10/11/2002 02:36'!
rollbackTransactionInSession: session 
	self getResultOfQuery: 'ROLLBACK' inSession: session! !


!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:43'!
current
	current isNil
		ifTrue: [current _ self defaultConnectionClass basicNew initialize.
			Smalltalk addToShutDownList: self.
			Smalltalk addToStartUpList: self].
	^ current! !

!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/11/2002 15:54'!
defaultConnectionClass
	^ PgSqlConnectionManager! !

!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:10'!
new
	^ self error: 'Singleton, use >>current'! !

!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:51'!
release
	self releaseConnections.
			current _ nil! !

!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:50'!
releaseConnections
	current isNil
		ifFalse: [current release]! !

!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:51'!
shutDown
	self releaseConnections! !

!ConnectionManager class methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:51'!
startUp
self releaseConnections! !


!PackageManager methodsFor: 'initialize' stamp: 'WFB 10/9/2002 19:04'!
addPackage: packageName 
	(packages includesKey: packageName )ifTrue: [self error: 'Package ', packageName, 'already exists'].
	^packages at: packageName put: (Package newNamed: packageName)
	! !

!PackageManager methodsFor: 'initialize' stamp: 'WFB 10/10/2002 22:24'!
initialize
	packages _ Dictionary new! !

!PackageManager methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:16'!
connectionManager
	^ConnectionManager current! !

!PackageManager methodsFor: 'accessing' stamp: 'WFB 10/10/2002 22:24'!
packages
	^packages! !

!PackageManager methodsFor: 'accessing' stamp: 'WFB 10/11/2002 01:43'!
username
	^self connectionManager username! !

!PackageManager methodsFor: 'class changes' stamp: 'WFB 10/9/2002 19:18'!
getPackageForClass: class
	^currentPackage! !

!PackageManager methodsFor: 'class changes' stamp: 'WFB 10/9/2002 19:18'!
recordClassChange: changeType forClass: class
	| pkg |
	pkg := self getPackageForClass: class.
	pkg recordClassChange: changeType forClass: class! !


!PackageManager class methodsFor: 'instance creation' stamp: 'WFB 10/9/2002 18:59'!
current
	current isNil ifTrue: [current := self basicNew initialize].
	^current! !

!PackageManager class methodsFor: 'instance creation' stamp: 'WFB 10/9/2002 18:58'!
new
	^self error: 'Singleton'! !


!PersistentObject methodsFor: 'testing' stamp: 'WFB 10/11/2002 01:31'!
isClean
	^self isNew not and: [self isDirty not].! !

!PersistentObject methodsFor: 'testing' stamp: 'WFB 10/11/2002 01:30'!
isDirty
	self subclassResponsibility! !

!PersistentObject methodsFor: 'testing' stamp: 'WFB 10/11/2002 01:30'!
isNew
	self subclassResponsibility! !

!PersistentObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 04:03'!
insertInSession: session 
	self preInsert. 
	self connectionManager getResultOfQuery: self insertString inSession: session! !

!PersistentObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 01:41'!
insertString
	| str queryColumns instVarNames val |
	str _ ReadWriteStream on: String new.
	str nextPutAll: 'INSERT INTO ';
		 nextPutAll: self class tableName;
		 nextPutAll: ' ( '.
	queryColumns _ self class queryColumns.
	queryColumns
		do: [:col | str nextPutAll: col]
		separatedBy: [str nextPutAll: ', '].
	str nextPutAll: ' ) values ('.
	instVarNames _ self class allInstVarNames.
	queryColumns
		keysAndValuesDo: [:i :elem | 
			val _ self
						instVarAt: (instVarNames
								indexOf: (queryColumns at: i)).
			str nextPutAll: val sqlString.
		i = queryColumns size ifFalse: [str nextPutAll: ', ']].
	str nextPutAll: ')'.
	^ str contents! !

!PersistentObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 01:41'!
preInsert! !

!PersistentObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 03:07'!
storeInSession: session 
	self isClean
		ifTrue: [^ #wasClean].
	(self isNew
			or: [self isDirty])
		ifTrue: [self insertInSession: session. ^ #updated]! !

!PersistentObject methodsFor: 'initialize' stamp: 'WFB 10/11/2002 00:55'!
initialize! !

!PersistentObject methodsFor: 'initialize' stamp: 'WFB 10/11/2002 12:47'!
initializeFromArray: anArray 
	| resultColumns instVarNames queryColumns |
	resultColumns _ self class resultColumns.
	queryColumns _ self class queryColumns.
	"Reorder the resultcolumns"
	resultColumns _ (queryColumns
				select: [:elem | resultColumns includes: elem])
				, (resultColumns
						select: [:elem | (queryColumns includes: elem) not]).
	instVarNames _ self class allInstVarNames.
	anArray
		keysAndValuesDo: [:i :elem | self
				instVarAt: (instVarNames
						indexOf: (resultColumns at: i))
				put: elem]! !

!PersistentObject methodsFor: 'tools' stamp: 'WFB 10/11/2002 02:21'!
connectionManager
	^self packageManager connectionManager! !

!PersistentObject methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:51'!
decode: aString 
	aString isNil ifTrue: [^nil].
	^ (Base64MimeConverter
		mimeDecodeToChars: (ReadStream on: aString)) contents! !

!PersistentObject methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:06'!
getPreviousVersion
	^ self class getObjectWithID: self trace! !

!PersistentObject methodsFor: 'tools' stamp: 'WFB 10/11/2002 02:21'!
packageManager
	^PackageManager current! !


!ClassDefinitionRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 00:00'!
initializeForClass: aClass 
	classRecord _ ClassRecord newForClass: aClass.
	metaclassRecord _ ClassRecord newForMetaclass: aClass! !

!ClassDefinitionRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 03:19'!
initializeForClass: aClass inPackage: aPackage 
	self initializeForClass: aClass.
	package _ aPackage! !

!ClassDefinitionRecord methodsFor: 'initialize' stamp: 'WFB 10/10/2002 18:21'!
initializeFromArray: anArray 
	super initializeFromArray: anArray.
	classRecord _ ClassRecord getObjectWithID: classRef.
	metaclassRecord _ ClassRecord getObjectWithID: metaclassRef! !

!ClassDefinitionRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 00:58'!
updateForClass: aClass 
	classRecord updateForClass: aClass.
	metaclassRecord updateForMetaclass: aClass
! !

!ClassDefinitionRecord methodsFor: 'accessing' stamp: 'WFB 10/10/2002 23:04'!
className
	^ classRecord name! !

!ClassDefinitionRecord methodsFor: 'accessing' stamp: 'WFB 10/11/2002 16:18'!
classRecord
	^classRecord! !

!ClassDefinitionRecord methodsFor: 'accessing' stamp: 'WFB 10/11/2002 11:29'!
name: aString 
	"Used for renaming messages"
	classRecord name: aString.
	metaclassRecord name: aString, ' class'! !

!ClassDefinitionRecord methodsFor: 'storage' stamp: 'WFB 10/11/2002 12:55'!
insertInSession: session 
	classRecord storeInSession: session.
	metaclassRecord storeInSession: session.
	classRef _ classRecord primaryKey.
	metaclassRef _ metaclassRecord primaryKey.
	super insertInSession: session! !

!ClassDefinitionRecord methodsFor: 'storage' stamp: 'WFB 10/11/2002 12:54'!
preInsert
	packageRef _ package primaryKey! !

!ClassDefinitionRecord methodsFor: 'testing' stamp: 'WFB 10/11/2002 13:56'!
isDirty
	^ true! !

!ClassDefinitionRecord methodsFor: 'testing' stamp: 'WFB 10/11/2002 13:56'!
isNew
	^ true! !


!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:29'!
connectionManager
	^PackageManager current connectionManager! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/10/2002 16:56'!
noColumns
	^ #()! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:15'!
noQueryColumns
	"These instVarNames are not to be included in a SELECT query generation"
	^ #()! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:15'!
noResultColumns
	"These instVarNames are not to be filled with a query result"
	^ #()! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:16'!
queryColumns
	^ self allInstVarNames asOrderedCollection removeAll: self noQueryColumns;
		 yourself! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:16'!
resultColumns
	^ self allInstVarNames asOrderedCollection removeAll: self noResultColumns;
		 yourself! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:17'!
selectArgsString
	| str |
	str _ ReadWriteStream on: String new.
	str nextPutAll: 'select '.
	self queryColumns
		do: [:elem | str nextPutAll: 'A.';
				 nextPutAll: elem]
		separatedBy: [str nextPutAll: ', '].
	^ str contents! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:17'!
selectJoinClauses
	^ #()! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:23'!
selectString
	^ self selectStringFromTables: self selectTables where: self selectWhereClauses , #('A.primarykey = ' )! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:33'!
selectStringFromTables: tables where: whereClauses 
	| str |
	str _ ReadWriteStream on: String new.
	str nextPutAll: self selectArgsString.
	str nextPutAll: ' FROM '.
	tables
		do: [:table | str nextPutAll: table]
		separatedBy: [str nextPutAll: ', '].
	str nextPutAll: ' WHERE '.
	whereClauses
		do: [:whereClause | str nextPutAll: whereClause]
		separatedBy: [str nextPutAll: ' AND '].
	^ str contents! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/10/2002 17:51'!
selectTables
	^ OrderedCollection with: self tableName, ' A'! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/10/2002 17:48'!
selectWhereClauses
	^ #()! !

!PersistentObject class methodsFor: 'tools' stamp: 'WFB 10/10/2002 16:37'!
tableName
	^'tw_', self name! !

!PersistentObject class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 12:22'!
getObjectWithID: primarykey 
	| arr |
	arr _ PackageManager current connectionManager getResultOfQuery: self selectString , primarykey asString.
	arr size = 1
		ifTrue: [^ self new initializeFromArray: arr first].
	self error: 'Not found'! !

!PersistentObject class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 00:55'!
new
	^super new initialize! !


!ClassDefinitionRecord class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 12:55'!
getAllInPackage: aPackage 
	| primaryKey arr query |
	primaryKey _ aPackage primaryKey.
	query _ self selectStringFromTables: self selectTables where: self selectWhereClauses , #('A.packageref = ' ).
	arr _ self connectionManager getResultOfQuery: query , primaryKey asString , ' order by definitionOrder'.
	^ arr
		collect: [:elem | self new initializeFromArray: elem]! !

!ClassDefinitionRecord class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 03:18'!
newForClass: aClass inPackage: aPackage 
	^ self new initializeForClass: aClass inPackage: aPackage ! !

!ClassDefinitionRecord class methodsFor: 'tools' stamp: 'WFB 10/11/2002 03:18'!
noQueryColumns
	^ super noQueryColumns , #(#classRecord #metaclassRecord package)! !

!ClassDefinitionRecord class methodsFor: 'tools' stamp: 'WFB 10/11/2002 03:18'!
noResultColumns
	^ super noResultColumns , #(#classRecord #metaclassRecord package)! !

!ClassDefinitionRecord class methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:18'!
tableName
	^'tw_pkgclasses'! !


!PersistentPKObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 12:56'!
insertInSession: session 
	| pk |
	pk _ self connectionManager getResultOfQuery: self class pkString inSession: session.
	primaryKey _ pk first first.
	super insertInSession: session! !

!PersistentPKObject methodsFor: 'accessing' stamp: 'WFB 10/11/2002 12:54'!
primaryKey
	^ primaryKey! !


!Blob methodsFor: 'conversion' stamp: 'WFB 10/10/2002 17:27'!
asString
	^ (Base64MimeConverter mimeDecodeToChars: (ReadStream on: blobdata)) contents! !

!Blob methodsFor: 'conversion' stamp: 'WFB 10/11/2002 14:05'!
setString: aString 
	self setString: aString type: 2! !

!Blob methodsFor: 'conversion' stamp: 'WFB 10/11/2002 14:04'!
setString: aString type: type
	blobtype _ type.
	blobdata _ (Base64MimeConverter
				mimeNoLinebreakEncode: (ReadStream on: aString)) contents asString! !


!PersistentPKObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 02:14'!
pkString
	^ 'select nextVal(''' , self tableName , '_sequence'')'! !


!Blob class methodsFor: 'tools' stamp: 'WFB 10/11/2002 14:05'!
storeData: aString inSession: session 
	| blob |
	blob _ Blob new.
	blob setString: aString type: 1.
	blob insertInSession: session.
	^ blob primaryKey! !

!Blob class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:54'!
storeString: aString inSession: session 
	| blob |
	blob _ Blob new.
	blob setString: aString.
	blob insertInSession: session.
	^ blob primaryKey! !


!PersistentTraceObject methodsFor: 'accessing' stamp: 'WFB 10/11/2002 01:32'!
markDirty
	self isClean
		ifFalse: [^ self].
	trace _ primarykey.
	primarykey _ nil! !

!PersistentTraceObject methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:38'!
name
	^name! !

!PersistentTraceObject methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:40'!
name: anObject
	name := anObject! !

!PersistentTraceObject methodsFor: 'accessing' stamp: 'WFB 10/10/2002 22:38'!
trace
	^trace! !

!PersistentTraceObject methodsFor: 'initialize' stamp: 'WFB 10/11/2002 00:38'!
initializeFromArray: anArray 
	super initializeFromArray: anArray.
	timestamp _ Time dateAndTimeFromSeconds: timestamp + 2922938387.
	name := name asSymbol.! !

!PersistentTraceObject methodsFor: 'testing' stamp: 'WFB 10/11/2002 13:49'!
isDirty
	^ primaryKey isNil
		and: [trace isNil not]! !

!PersistentTraceObject methodsFor: 'testing' stamp: 'WFB 10/11/2002 13:49'!
isNew
	^ primaryKey isNil
		and: [trace isNil]! !

!PersistentTraceObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 02:38'!
preInsert
	timestamp _ self class timestampNow.
	username _ self packageManager username.
	super preInsert! !

!PersistentTraceObject methodsFor: 'printing' stamp: 'WFB 10/11/2002 11:40'!
printOn: aStream
	
	super printOn: aStream.
	aStream nextPutAll: ' named '.
	name printOn: aStream ! !


!MethodRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 12:58'!
initializeForMethod: selector forClass: class 
	name := selector.
	timestamp := self class timestampNow.
	classname := class theNonMetaClass fullName.
	metastring := class isMeta ifTrue: ['T'] ifFalse: ['F'].
	protocolName := class organization categoryOfElement: selector.
	source := (class methodDict at: selector) getSource asString! !

!MethodRecord methodsFor: 'initialize' stamp: 'WFB 10/10/2002 17:59'!
initializeFromArray: anArray 
	super initializeFromArray: anArray.
	source _ self decode: source! !

!MethodRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 01:10'!
updateForMethod: selector forClass: class 
	self initializeForMethod: selector forClass: class.
	self markDirty! !

!MethodRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 13:04'!
updateMethod: selector forClass: class
	self initializeForMethod: selector forClass: class.
	self markDirty! !

!MethodRecord methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:37'!
classname
	^classname! !

!MethodRecord methodsFor: 'accessing' stamp: 'WFB 10/11/2002 12:58'!
insertInSession: session 
	sourcecodeId := Blob storeString: source inSession: session.
	super insertInSession: session! !

!MethodRecord methodsFor: 'testing' stamp: 'WFB 10/11/2002 01:24'!
isMeta
	^metastring = 'T'! !

!MethodRecord methodsFor: 'storage' stamp: 'WFB 10/11/2002 12:55'!
createRelationto: package inSession: session 
	| query |
	query _ 'INSERT INTO tw_methods (packageref, methodref) values (' , package primaryKey asString , ', ' , self primaryKey asString , ')'.
	self connectionManager getResultOfQuery: query inSession: session! !


!PersistentTraceCommentObject methodsFor: 'initialize' stamp: 'WFB 10/11/2002 12:50'!
initializeFromArray: anArray 
	super initializeFromArray: anArray.
	comment _ self decode: comment! !

!PersistentTraceCommentObject methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:30'!
comment
	^comment
! !

!PersistentTraceCommentObject methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:33'!
comment: anObject 
	comment = anObject ifTrue: [^self].
	comment _ anObject.
	self markDirty! !

!PersistentTraceCommentObject methodsFor: 'storage' stamp: 'WFB 10/11/2002 16:26'!
insertInSession: session 
	(comment isNil
			or: [comment = ''])
		ifTrue: [commentId _ 0]
		ifFalse: [commentId _ Blob storeString: comment inSession: session].
	super insertInSession: session! !


!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/10/2002 23:36'!
buildDefinitionForClass: aClass 
	| typeOfClass str |
	typeOfClass _ aClass typeOfClass.
	typeOfClass = #normal
		ifTrue: [typeOfClass _ #none].
	str _ ReadWriteStream on: String new.
	str nextPutAll: aClass namespace;
		 nextPutAll: ' defineClass: #';
		 nextPutAll: aClass name;
		 cr;
		 tab;
		 nextPutAll: 'superclass: #{';
		 nextPutAll: aClass superclass fullName; nextPut: $};
		 cr;
		 tab;
		 nextPutAll: 'indexedType: #';
		 nextPutAll: typeOfClass;
		 cr;
		 tab;
		 nextPutAll: 'private: false';
		 cr;
		 tab;
		 nextPutAll: 'instanceVariableNames: '''.
	aClass instVarNames
		do: [:elem | str nextPutAll: elem]
		separatedBy: [str space].
	str nextPut: $';
		 cr;
		 tab.
	str nextPutAll: 'classInstanceVariableNames: '''.
	aClass class instVarNames
		do: [:elem | str nextPutAll: elem]
		separatedBy: [str space].
	str nextPut: $';
		 cr;
		 tab.
	str nextPutAll: 'imports: ''''';
		 cr;
		 tab;
		 nextPutAll: 'category: ''';
		 nextPutAll: aClass category;
		 nextPut: $'.
	^str contents
! !

!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/10/2002 23:59'!
buildDefinitionForMetaclass: aClass 
	| str |
	str _ ReadWriteStream on: String new.
	str nextPutAll: aClass fullName;
		 nextPutAll: ' class
	instanceVariableNames: '''.
	aClass class instVarNames
		do: [:elem | str nextPutAll: elem]
		separatedBy: [str space].
	str nextPut: $'.
	^ str contents! !

!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 12:57'!
initializeForClass: aClass 
	environmentString := 'Root.Smalltalk'.
	superclass := aClass superclass name.
	definition := self buildDefinitionForClass: aClass.
	environmentString := aClass namespace.
	name := aClass name.
	timestamp := self class timestampNow! !

!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 12:57'!
initializeForMetaclass: aClass 
	environmentString := 'Root.Smalltalk'.
	superclass := aClass superclass class name.
	definition := self buildDefinitionForMetaclass: aClass.
	environmentString := aClass namespace.
	name := aClass class name.
	timestamp := self class timestampNow! !

!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/10/2002 17:59'!
initializeFromArray: anArray 
	super initializeFromArray: anArray.
	definition _ self decode: definition! !

!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 00:59'!
updateForClass: aClass 
	self initializeForClass: aClass.
	self markDirty! !

!ClassRecord methodsFor: 'initialize' stamp: 'WFB 10/11/2002 00:59'!
updateForMetaclass: aClass 

	self initializeForMetaclass: aClass.
	self markDirty! !

!ClassRecord methodsFor: 'storage' stamp: 'WFB 10/11/2002 12:57'!
insertInSession: session 
	definitionId := Blob storeString: definition inSession: session.
	super insertInSession: session! !


!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
binfile
	^binfile! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
binfile: anObject
	binfile := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 13:31'!
blessinglevel
	^blessingLevel! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 13:31'!
blessinglevel: anObject 
	blessingLevel := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:52'!
changeSet
	^ changeSet! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 00:52'!
changeSet: anObject 
	changeSet _ anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 12:57'!
commentid
	^commentId! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 12:57'!
commentid: anObject 
	commentId := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
methodDefinitions
	^methodDefinitions! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
methodDefinitions: anObject
	methodDefinitions := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:09'!
name
	^ name! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
name: anObject
	name := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 13:31'!
parcelid
	^parcelId! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 13:31'!
parcelid: anObject 
	parcelId := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
primarykey
	^primarykey! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
primarykey: anObject
	primarykey := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 13:31'!
propertiesid
	^propertiesId! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/11/2002 13:31'!
propertiesid: anObject 
	propertiesId := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
timestamp
	^timestamp! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
timestamp: anObject
	timestamp := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
trace
	^trace! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
trace: anObject
	trace := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
username
	^username! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:07'!
username: anObject
	username := anObject! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
version
	^version! !

!Package methodsFor: 'accessing' stamp: 'WFB 10/10/2002 16:06'!
version: anObject
	version := anObject! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 15:13'!
addClass: aClass 
	| class |
	class _ aClass theNonMetaClass.
	(classDefinitions
		includesKey: class name)
		ifTrue: [^ self changeClass: class].
	classDefinitions
		at: class name
		put: (ClassDefinitionRecord newForClass: class inPackage: self)! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 14:32'!
addClassComment: aClass 
	| class |
	class _ aClass theNonMetaClass.
	(classDefinitions at: class name) classRecord comment: class organization classComment! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 17:25'!
addMethod: selector forClass: class 
	(self methodRecordNamed: selector forClass: class) isNil
		ifFalse: [^ self updateMethod: selector forClass: class].
	(class methodDict includesKey: selector) ifFalse: [^self].
	(self methodRecordsForClass: class)
		at: selector
		put: (MethodRecord newForMethod: selector forClass: class)! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 18:12'!
changeClass: aClass 
	| class |
	class _ aClass theNonMetaClass.
	(classDefinitions
		at: class name
		ifAbsent: [^ self addClass: class])
		updateForClass: class! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 17:23'!
insertInSession: session 
	| totalRecords classDefs methodDefs |
	propertiesId _ Blob storeData: properties inSession: session.
	version _ self getNewVersionNumberInSession: session.
	super insertInSession: session.
	classDefs _ classDefinitions values.
	methodDefs _ OrderedCollection new.
	methodDefinitions values
		do: [:elem | methodDefs addAll: elem values].
	totalRecords _ classDefs size + methodDefs size.
	Transcript cr; show: 'Clean classDefs :'; show: (classDefs
			select: [:elem | elem isClean]) size asString.
	Transcript cr; show: 'Clean methodDefs :'; show: (methodDefs
			select: [:elem | elem isClean]) size asString.
	classDefs
		keysAndValuesDo: [:i :elem | 
			elem storeInSession: session.
			self progressIndicate: i of: totalRecords].
	methodDefs
		keysAndValuesDo: [:i :elem | 
			elem storeInSession: session.
			elem createRelationto: self inSession: session.
			self progressIndicate: i + classDefs size of: totalRecords]! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 14:38'!
methodRecordNamed: selector forClass: class 
	^ (self methodRecordsForClass: class)
		at: selector
		ifAbsent: []! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 14:35'!
methodRecordsForClass: class 
	^(methodDefinitions at: class ifAbsentPut: [Dictionary new])
! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 14:29'!
removeClass: aClassName 
	(classDefinitions includesKey: aClassName) 
		ifTrue: [
	classDefinitions removeKey: aClassName]! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 14:40'!
removeSelector: selector forClass: class 
	| methodDef |
	(methodDef _ self methodRecordNamed: selector forClass: class) isNil
		ifTrue: [^ self].
(self methodRecordsForClass: class) removeKey: methodDef selector! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 14:30'!
renameClass: oldClassName to: newClassName 
	| classDef |
	classDef _ classDefinitions at: oldClassName.
	classDefinitions removeKey: oldClassName.
	classDef name: newClassName.
	classDefinitions at: newClassName put: classDef! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 01:02'!
storeOutChangedMessages: changes forClass: class 
	changes
		keysAndValuesDo: [:selector :changeType | changeType = #add
				ifTrue: [self addMethod: selector forClass: class]
				ifFalse: [changeType = #change
						ifTrue: [self updateMethod: selector forClass: class]
						ifFalse: [(changeType = #remove or: [changeType = #addedThenRemoved])
								ifTrue: [self removeSelector: selector forClass: class]
								ifFalse: [self error: 'Unknown changeType']]]]! !

!Package methodsFor: 'class change' stamp: 'WFB 10/11/2002 01:02'!
updateMethod: selector forClass: class 
	| methodDef |
	(methodDef _ self methodRecordNamed: selector forClass: class) isNil
		ifTrue: [^ self addMethod: selector forClass: class].
	methodDef updateMethod: selector forClass: class! !

!Package methodsFor: 'initialize' stamp: 'WFB 10/11/2002 13:29'!
defaultProperties
	"Hackish plug since i don't know how to boss in/out vw boss.

The result can be obtained by evaluating following in VW:

stream := OrderedCollection new readWriteStream.
b := BinaryObjectStorage onNew:  stream.
b nextPut: (IdentityDictionary new).
str := String new: coll size.
stream contents keysAndValuesDo: [:i :elem | str at:  i put: elem asCharacter].
base64Stream :=  Base64EncodingWriteStream on: String new.
base64Stream lineBreaksEnabled: false.
base64Stream nextPutAll: stream contents.
base64Stream contents "
	^ 'Qk9TUyA3IAGAAAAADgAAADAAAAAKAAAAdicXDkInCh1cCBQACCcFAnInChmugAQ1zwkUGZgiEg2AgQAE6YUGJrVDb3JlLklkZW50aXR5RGljdGlvbmFyeUNvcmUuQXJyYXkAAAAGAAAACAAAAAAAAUADAAAAAHRhbGx5dmFsdWVBcnJheQAKAA4AEgAAAAIAAAAIAAAAAAABQAsAAAAWd2l0aEtleXNBbmRWYWx1ZXM6ABoAHgAi'! !

!Package methodsFor: 'initialize' stamp: 'WFB 10/11/2002 14:26'!
initialize
	super initialize.
	classDefinitions _ Dictionary new.
	methodDefinitions _ Dictionary new.
	properties _ self decode: self defaultProperties! !

!Package methodsFor: 'initialize' stamp: 'WFB 10/11/2002 14:50'!
initializeFromArray: anArray 
	super initializeFromArray: anArray.
	properties _ self decode: properties.
	(ClassDefinitionRecord getAllInPackage: self)
		do: [:elem | classDefinitions at: elem className put: elem].
	(MethodRecord getAllInPackage: self)
		do: [:elem | (self methodRecordsForClass: elem classname)
				at: elem name
				put: elem]! !

!Package methodsFor: 'retrieval' stamp: 'WFB 10/11/2002 16:36'!
loadInNewChangeSetNamed: aString 
	^ self! !

!Package methodsFor: 'storage' stamp: 'WFB 10/11/2002 16:24'!
getNewVersionNumberInSession: session 
	| newVersionSuggestion res query |
	newVersionSuggestion _ self suggestNewVersionFor: version.
	[query _ 'select count(*) from tw_package where name = ' , name sqlString , ' AND version = ' , newVersionSuggestion sqlString.
	res _ self connectionManager getResultOfQuery: query inSession: session.
	res first first = '0']
		whileFalse: [newVersionSuggestion _ self suggestAlternateVersionFor: newVersionSuggestion].
	^ newVersionSuggestion! !

!Package methodsFor: 'storage' stamp: 'WFB 10/11/2002 02:18'!
preInsert
	name isNil
		ifTrue: [name _ changeSet name].
	version isNil
		ifTrue: [version _ '1.0'].
	super preInsert.
	trace isNil
		ifTrue: [trace := '0'].
! !

!Package methodsFor: 'storage' stamp: 'WFB 10/11/2002 11:56'!
progressIndicate: currentPos of: totalRecords 
	currentPos = 1
		ifTrue: [Transcript cr; show: 'Start writing out '; show: totalRecords asString; show: ' records: '].
	currentPos = totalRecords
		ifTrue: [Transcript show: 'Done.'].
	currentPos \\ 10 = 0
		ifTrue: [Transcript show: currentPos asString]
		ifFalse: [Transcript show: '.']! !

!Package methodsFor: 'storage' stamp: 'WFB 10/11/2002 12:02'!
store
	self connectionManager
		sessionDo: [:session | [self connectionManager beginTransactionInSession: session.
			self insertInSession: session.
			self connectionManager commitTransactionInSession: session]
				ifCurtailed: [self connectionManager rollbackTransactionInSession: session]]! !

!Package methodsFor: 'storage' stamp: 'WFB 10/11/2002 16:13'!
suggestAlternateVersionFor: aString 
	^ aString, '.1'! !

!Package methodsFor: 'storage' stamp: 'WFB 10/11/2002 16:21'!
suggestNewVersionFor: aString 
	| last |
	aString isNil ifTrue: [^'1.0'].
	last _ aString copyAfterLast: $..
	last isEmpty
		ifTrue: [last _ ' 1.0']
		ifFalse: [last _ (last asInteger + 1) asString].
	^ (aString copyUpToLast: $.)
		, '.' , last! !


!PersistentTraceObject class methodsFor: 'tools' stamp: 'WFB 10/10/2002 23:50'!
timestampNow
	"Peeked at VW implementation"
	^((Time now asSeconds + Date today asSeconds) - 2922938387)! !


!MethodRecord class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:15'!
noQueryColumns
	^ super noQueryColumns , #(#source )! !

!MethodRecord class methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:01'!
selectArgsString
	^ super selectArgsString , ', B.blobdata'! !

!MethodRecord class methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:01'!
selectTables
	^ super selectTables , #('TW_BLOB B' )! !

!MethodRecord class methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:01'!
selectWhereClauses
	^ super selectWhereClauses , #('B.primarykey = A.sourcecodeid' )! !

!MethodRecord class methodsFor: 'tools' stamp: 'WFB 10/10/2002 18:03'!
tableName
	^'tw_method'! !

!MethodRecord class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 12:55'!
getAllInPackage: aPackage 
	| primaryKey arr query |
	primaryKey _ aPackage primaryKey.
	query _ self selectStringFromTables: self selectTables , #('tw_methods P' ) where: self selectWhereClauses , #('P.methodref = A.primaryKey' 'P.packageref = ' ).
	arr _ self connectionManager getResultOfQuery: query , primaryKey asString.
	^ arr
		collect: [:elem | self new initializeFromArray: elem]! !

!MethodRecord class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 00:48'!
newForMethod: method forClass: class 
	^ self new initializeForMethod: method forClass: class ! !


!PersistentTraceCommentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:16'!
noQueryColumns
	^ super noQueryColumns , #(#comment )! !

!PersistentTraceCommentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:10'!
selectArgsString
	^ super selectArgsString , ', C.blobdata'! !

!PersistentTraceCommentObject class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:35'!
selectTables
	| st last |
	st _ super selectTables.
	last _ st removeLast , ' LEFT OUTER JOIN tw_blob C ON (A.commentId = C.primarykey )'.
	st add: last.
	^ st! !


!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 12:55'!
getAllInPackage: aPackage 
	| primaryKey arr query |
	primaryKey _ aPackage primaryKey.
	query _ self selectStringFromTables: self selectTables , #('tw_pkgclasses P' ) where: self selectWhereClauses , #('P.classref = A.primarykey' 'P.packageref = ' ).
	arr _ self connectionManager getResultOfQuery: query , primaryKey asString.
	^ arr
		collect: [:elem | self new initializeFromArray: elem]! !

!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/10/2002 23:15'!
newForClass: aClass
	^self new initializeForClass: aClass! !

!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/10/2002 23:59'!
newForMetaclass: aClass 
	^ self new initializeForMetaclass: aClass! !

!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/11/2002 00:15'!
noQueryColumns
	^ super noQueryColumns , #(#definition )! !

!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/10/2002 17:40'!
selectArgsString
	^super selectArgsString, ', B.blobdata'! !

!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/10/2002 17:51'!
selectTables
	^ super selectTables , #('TW_BLOB B')! !

!ClassRecord class methodsFor: 'instance creation' stamp: 'WFB 10/10/2002 17:51'!
selectWhereClauses
	^ super selectWhereClauses , #('B.primarykey = A.definitionid')! !


!DataElement class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:09'!
noQueryColumns
	^ super noQueryColumns , #( #definition )! !

!DataElement class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:09'!
selectArgsString
	^ super selectArgsString , ', D.blobdata'! !

!DataElement class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:09'!
selectTables
	^ super selectTables , #('TW_BLOB D' )! !

!DataElement class methodsFor: 'tools' stamp: 'WFB 10/11/2002 12:09'!
selectWhereClauses
	^ super selectWhereClauses , #('D.primarykey = A.definitionId')! !


!Package class methodsFor: 'tools' stamp: 'WFB 10/11/2002 13:09'!
noQueryColumns
	^ super noQueryColumns , #(#classDefinitions #methodDefinitions #changeSet #properties)! !

!Package class methodsFor: 'tools' stamp: 'WFB 10/11/2002 00:53'!
noResultColumns
	^ super noResultColumns , #(#classDefinitions #methodDefinitions changeSet)! !

!Package class methodsFor: 'tools' stamp: 'WFB 10/11/2002 13:08'!
selectArgsString
	^ super selectArgsString , ', P.blobdata'! !

!Package class methodsFor: 'tools' stamp: 'WFB 10/11/2002 13:09'!
selectTables
	^ super selectTables , #('TW_BLOB P' )! !

!Package class methodsFor: 'tools' stamp: 'WFB 10/11/2002 13:09'!
selectWhereClauses
	^ super selectWhereClauses , #('P.primarykey = A.propertiesId' )! !


!PgSqlConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:01'!
defaultConnectionArgs

	^ PGConnectionArgs
		hostname: host
		portno: port
		databaseName: databaseName
		userName: username
		password: password! !

!PgSqlConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:00'!
newConnection
	^ PGConnection preferredConnectionClass new! !

!PgSqlConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:22'!
retrConnection
	| aConnection |
	aConnection _ self newConnection.
	aConnection startup: self defaultConnectionArgs.
	^ aConnection! !

!PgSqlConnectionManager methodsFor: 'as yet unclassified' stamp: 'WFB 10/7/2002 22:52'!
terminateConnection: aConnection 
	aConnection isNil ifFalse:[
	aConnection terminate].
	super terminateConnection: aConnection!
]style[(21 11 32 11 14 5 22 11)f1b,f1cblue;b,f1,f1cblue;i,f1,f1cmagenta;,f1,f1cblue;i! !


!String methodsFor: 'StORE' stamp: 'WFB 10/11/2002 02:44'!
sqlString
	^'''',self asString, ''''! !


!UndefinedObject methodsFor: 'StORE' stamp: 'WFB 10/11/2002 01:40'!
sqlString
	^'NULL'! !

PgSqlConnectionManager removeSelector: #closeConnection:!
PgSqlConnectionManager removeSelector: #getConnection!
Package class removeSelector: #columns!
Package class removeSelector: #createDBTable!
Package class removeSelector: #getObjectWithID:!
Package class removeSelector: #noColumns!
Package class removeSelector: #selectString!
ClassRecord class removeSelector: #columns!
ClassRecord class removeSelector: #noColumns!
ClassRecord class removeSelector: #noResultColumns!
ClassRecord class removeSelector: #selectString!
ClassRecord class removeSelector: #selectWhereClausesString!
PersistentTraceCommentObject class removeSelector: #noColumns!
PersistentTraceCommentObject class removeSelector: #selectJoinClauses!
PersistentTraceCommentObject class removeSelector: #selectWhereClauses!
MethodRecord class removeSelector: #noColumns!
MethodRecord class removeSelector: #noResultColumns!
Package removeSelector: #addClass:definitionOrder:!
Package removeSelector: #classDefinitionNamed:!
Package removeSelector: #classDefinitions!
Package removeSelector: #classDefinitions:!
Package removeSelector: #getNewVersionNumber!
Package removeSelector: #loadInNewChangeSet!
Package removeSelector: #name1!
MethodRecord removeSelector: #hasRelation!
MethodRecord removeSelector: #markDirty!
Blob class removeSelector: #storeString:InSession:!
Blob removeSelector: #insertString!
PersistentPKObject removeSelector: #primarykey!
ClassDefinitionRecord class removeSelector: #newForClass:definitionOrder:!
ClassDefinitionRecord class removeSelector: #noColumns!
PersistentObject class removeSelector: #columns!
ClassDefinitionRecord removeSelector: #initializeForClass:definitionOrder:!
ClassDefinitionRecord removeSelector: #storeInSession:!
PersistentObject removeSelector: #noColumns!
ConnectionManager class removeSelector: #default!
ConnectionManager class removeSelector: #getResultOfQuery:!
ConnectionManager class removeSelector: #shutDown:!
ConnectionManager class removeSelector: #startup:!
ConnectionManager removeSelector: #maxConnections!
ChangeSet removeSelector: #storeOutClassDefinition:on:definitionOrder:!
