StoreSourceCodeManager.st
author Claus Gittinger <cg@exept.de>
Fri, 25 Aug 2006 18:02:38 +0200
changeset 1731 16af565d0676
parent 1530 72861343b2a2
child 1732 61f9b9c98087
permissions -rw-r--r--
db connection established

"
 COPYRIGHT (c) 2006 eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

"{ Package: 'stx:libbasic3' }"

AbstractSourceCodeManager subclass:#StoreSourceCodeManager
	instanceVariableNames:''
	classVariableNames:'Verbose Connection DefaultDBInfo DBInfoPerModule'
	poolDictionaries:''
	category:'System-SourceCodeManagement'
!

Object subclass:#DBInfo
	instanceVariableNames:'hostName dbName userName password'
	classVariableNames:''
	poolDictionaries:''
	privateIn:StoreSourceCodeManager
!

!StoreSourceCodeManager class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    WARNING:
        this class is incomplete and provided as a sceletton
        if CVS is not to be used as a SourceCodeManager.
        We highly recommend to use CVS.

    SourceCodeManager which accesses sourcecode through a Store Database.
    This class is part of ongoing development and not yet released for public use.
"
! !

!StoreSourceCodeManager class methodsFor:'initialization'!

connectToDatabase
    |session|

    SQL::SQLError handle:[:ex |
        self warn:('Failed to connect to Database:\\' withCRs,ex description).
        ^ self.
    ] do:[
        session := self tryToConnectToDatabase:(self defaultDBInfo).
    ].

    session isNil ifTrue:[
        self warn:'OOPS - Failed to connect to Database'.
        ^ self
    ].
    Connection := session.
self halt.
!

tryToConnectToDatabase:dbInfo
    |session|

    session := SQL::ODBCSession new.
    session 
        connectWithUsername:(dbInfo userName) 
        password:(dbInfo password) 
        dbname:(dbInfo dbName).

    (session isConnected) ifFalse:[
        ^ nil.
    ].
    ^ session
! !

!StoreSourceCodeManager class methodsFor:'accessing'!

dbName
    ^ self defaultDBInfo dbName
!

dbName:aString
    self defaultDBInfo dbName:aString.
!

defaultDBInfo
    DefaultDBInfo isNil ifTrue:[
        DefaultDBInfo := DBInfo new
    ].
    ^ DefaultDBInfo
!

hostAndDBName
    ^ self defaultDBInfo hostAndDBName
!

hostAndDBName:aString
    self defaultDBInfo hostAndDBName:aString.
!

hostName
    ^ self defaultDBInfo hostName
!

hostName:aString
    self defaultDBInfo hostName:aString.
!

newDBInfo
    ^ DBInfo new
!

password
    ^ self defaultDBInfo password
!

password:aString
    self defaultDBInfo password:aString.
!

repositoryInfoPerModule
    ^ DBInfoPerModule ? #()

    "Created: / 16-08-2006 / 11:06:09 / cg"
!

repositoryInfoPerModule:aCollectionOfDBinfos
    DBInfoPerModule := aCollectionOfDBinfos

    "Created: / 16-08-2006 / 11:06:09 / cg"
!

userName
    ^ self defaultDBInfo userName
!

userName:aString
    self defaultDBInfo userName:aString.
! !

!StoreSourceCodeManager class methodsFor:'queries'!

managerTypeName
    ^ 'Store DB'

    "Created: / 16-08-2006 / 11:06:09 / cg"
! !

!StoreSourceCodeManager class methodsFor:'testing'!

isExperimental
    ^ true "false"

    "Created: / 16-08-2006 / 11:23:09 / cg"
!

isStore
    ^ true

    "Created: / 16-08-2006 / 10:59:06 / cg"
! !

!StoreSourceCodeManager::DBInfo methodsFor:'accessing'!

dbName
    ^ dbName
!

dbName:something
    dbName := something.
!

hostAndDBName
    hostName isEmptyOrNil ifTrue:[ ^ dbName ].
    dbName isEmptyOrNil ifTrue:[ self halt. ^ hostName ].
    ^ dbName,'@',hostName
!

hostAndDBName: aString
    |idx|

    idx := aString indexOf:$@.
    idx == 0 ifTrue:[
        dbName := aString.
        hostName := nil.
    ] ifFalse:[
        dbName := aString copyTo:idx-1.
        hostName := (aString copyFrom:idx+1).
    ]
!

hostName
    ^ hostName
!

hostName:something
    hostName := something.
!

hostName:hostNameArg dbName:dbNameArg userName:userNameArg password:passwordArg 
    "set instance variables (automatically generated)"

    hostName := hostNameArg.
    dbName := dbNameArg.
    userName := userNameArg.
    password := passwordArg.
!

password
    ^ password
!

password:something
    password := something.
!

userName
    ^ userName
!

userName:something
    userName := something.
! !

!StoreSourceCodeManager class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic3/StoreSourceCodeManager.st,v 1.2 2006-08-25 16:02:38 cg Exp $'
! !