Personal tools
You are here: Home University 2nd Licence Génie logiciel ConfMan Package (html)
Document Actions

ConfMan Package (html)

by jfroche last modified 2006-11-20 01:01

Conference Manager written in Smalltalk - These are the base classes

ConfMan.st

'From VisualWorks® NonCommercial, 7.3.1 of April 20, 2005 on December 26, 2005 at 1:18:31 am'!
"Package ConfMan*"!


Smalltalk defineClass: #KeywordsContainer
	superclass: #{Core.SortedCollection}
	indexedType: #objects
	private: false
	instanceVariableNames: ''
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

KeywordsContainer comment:
'KeywordsContainer 

a sorted collection that contains keywords 


'!

Smalltalk defineClass: #SecureObject
	superclass: #{Core.Object}
	indexedType: #none
	private: false
	instanceVariableNames: 'membershipManager permissionManager parent '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

SecureObject comment:
'SecureObject 

SecureObject knows all about her security (the SecureObject knows who and what he can do on this SecureObject )

Instance Variables:
	membershipManager	<MembershipManager>	description of membershipManager
	permissionManager	<PermissionManager>	description of permissionManager

'!

Smalltalk defineClass: #Group
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'name '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Group comment:
'Group 

Instance Variables:
	name	<Object | RemoteObject>	the name of the Group

'!

Smalltalk defineClass: #Comment
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'user rating text '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Comment comment:
'Comment 

It''s a comment about an Article.
All Comment about an Article are in a CommentContainer

Instance Variables:
	rating <Object | Proxy>	A score between 0 and 5 for the Article
	text    <Object | Proxy>	The comment text itself
	user   <Object | Proxy>	The User who made the comment

'!

Smalltalk defineClass: #Talk
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'article room dateTimeBegin dateTimeEnd '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Smalltalk defineClass: #UserManager
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'sharedSkills usersDictionary '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

UserManager comment:
'UserManager .

Instance Variables:
	sharedSkills	      <KeywordsContainer>  contains Skill of at least one User
	usersDictionary	<Dictionary>	               list of User

'!

Smalltalk defineClass: #ConferenceManager
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'userManager confContainer groupManager locationsContainer '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

ConferenceManager comment:
'ConferenceManager 

ConferenceManager contain the 3 main structures of the applications

Instance Variables:
	confContainer	<Object | Proxy>	   contain Conference
	groupManager	<GroupManager>   manage Group
	userManager	<UserManager>	   manage User

'!

Smalltalk defineClass: #Conference
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'name location keywords articleContainer articleDeadline commentsDeadline notificationDeadline beginDate endDate expirationDate lecturer userManager mailHasBeenSent schedule '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Conference comment:
'Conference 

Instance Variables:
	articleContainer	<Object | Proxy>	 Contain the proposed Article for this Conference
	articleDeadline	<BlessingLevel | CharacterArray | CharacterBlock | JumpRecord | Magnitude | MethodFilter>	Deadline to propose an article for thjis Conference
	beginDate	<BlessingLevel | CharacterArray | CharacterBlock | JumpRecord | Magnitude | MethodFilter>	Date of beginning for this Conference
	commentsDeadline	<BlessingLevel | CharacterArray | CharacterBlock | JumpRecord | Magnitude | MethodFilter> Deadline for the lecturers to submit Comment about proposed Article
	endDate	<Object | Proxy>	 Dat of the end of the Conference
	expirationDate	<Object | Proxy>	
	keywords	<KeywordsContainer> l
	lecturer	<Object | RemoteObject>	description of lecturer
	name	<Object | RemoteObject>	name of the Conference
	notificationDeadline	<BlessingLevel | CharacterArray | CharacterBlock | JumpRecord | Magnitude | MethodFilter>	Deadline to notify to the authors of Article if they Article''s accept or not fot the Conference

'!

Smalltalk defineClass: #Article
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'title keywords user data comments openDiscussion lecturerApproved reviewerApproved '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Article comment:
'Article 

User can submit an Article for a Conference
All Article of a Conference are in an ArticleContainer

Instance Variables:
	comments	<CommentContainer> 	Contains a list of Comment made by lecturers about this Article
	data	      <Object | Proxy>	            The Article Itself
	keywords	<KeywordsContainer>	Keywords saying what the Article is talking about
	title	            <Object | RemoteObject>	Title of the Article
	user	      <Object | Proxy>	            The author of the Article

'!

Smalltalk defineClass: #Location
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'place address roomsContainer '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Smalltalk defineClass: #LocationsContainer
	superclass: #{Smalltalk.SecureObject}
	indexedType: #objects
	private: false
	instanceVariableNames: 'locations '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Smalltalk defineClass: #GroupManager
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'groupDictionary '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

GroupManager comment:
'GroupManager 

Contains all the Groups

Instance Variables:
	groupDictionary	<Dictionary>	 list of Group (acces key''s the name of the Group) 

'!

Smalltalk defineClass: #Schedule
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'talks '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Smalltalk defineClass: #RoomsContainer
	superclass: #{Smalltalk.SecureObject}
	indexedType: #objects
	private: false
	instanceVariableNames: 'rooms '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Smalltalk defineClass: #CommentContainer
	superclass: #{Smalltalk.SecureObject}
	indexedType: #objects
	private: false
	instanceVariableNames: 'comments '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

CommentContainer comment:
'CommentContainer 

There''s one CommentContainer per Article
It contain the list of Comment for an Article 

Instance Variables:
	comments	<Collection>	 Contain the Comment list for one Article


'!

Smalltalk defineClass: #PermissionManager
	superclass: #{Core.Object}
	indexedType: #none
	private: false
	instanceVariableNames: 'permissionDictionary membershipManager parent renderedObjectName '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

PermissionManager comment:
'PermissionManager 

Makes the link between  a Group or an User and permission

Instance Variables:
	membershipManager	<MembershipManager>	link between User and Group
	permissionDictionary	<Dictionary>	                  contains all permissions about this object

'!

Smalltalk defineClass: #Room
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'name capacity '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

Smalltalk defineClass: #MembershipManager
	superclass: #{Core.Object}
	indexedType: #none
	private: false
	instanceVariableNames: 'groupDictionary '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

MembershipManager comment:
'MembershipManager 

Makes the link between User and Group

Instance Variables:
	groupDictionary	<Dictionary>	 description of groupDictionary

'!

Smalltalk defineClass: #ConferenceContainer
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'conferences sharedKeywords '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

ConferenceContainer comment:
'ConferenceContainer 

Contains Conference

Instance Variables:
	conferences	<Dictionary>	 List of Conference
	sharedKeywords	<KeywordsContainer> list of keywords used previously or for other Conference

'!

Smalltalk defineClass: #ArticleContainer
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'articles '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

ArticleContainer comment:
'ArticleContainer 

There''s one ArticleContainer per Conference
It contains the list of Articles for a Conference 

Instance Variables:
	articles	<SortedCollection>	Contain the Article list for one Conference

'!

Smalltalk defineClass: #User
	superclass: #{Smalltalk.SecureObject}
	indexedType: #none
	private: false
	instanceVariableNames: 'name surname login password email skills '
	classInstanceVariableNames: ''
	imports: ''
	category: 'ConfMan'!

User comment:
'User 

Instance Variables:
	email	   <Object | Proxy>
	login	   <Object | Proxy>	
	name	   <Object | RemoteObject>  
	password  <Object | Proxy>	
	skills	   <KeywordsContainer>	description of skills
	surname	   <Object | Proxy>	

'!






















!SecureObject class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!SecureObject methodsFor: 'mutator'!

setOwner: anUserLogin
     self membershipManager setGroupMembers: (Set with: anUserLogin) groupName: 'Owner'.! !

!SecureObject methodsFor: 'initialize-release'!

initGroups
   self membershipManager setGroupMembers: (Set with:'root') groupName: 'Admin'.
   self membershipManager addGroupMembers: 'Owner'!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

	parent := nil.
	membershipManager := MembershipManager new initialize.
	permissionManager := (PermissionManager new initialize)
				membershipManager: membershipManager;
				renderedObjectName: self className.
	self initGroups.
	self initPermissions.
	^self!

initPermissions
   self permissionManager setPermission: 'View' members: (Set with:'Admin').
   self permissionManager setPermission: 'View Security Manager' members: (Set with:'Admin').
   self permissionManager setPermission: 'Delete' members: (Set with:'Admin').
   self permissionManager setPermission: 'Modify' members: (Set with:'Owner' with:'Admin').! !

!SecureObject methodsFor: 'accessing'!

permissionManager
  ^ permissionManager!

membershipManager
  ^ membershipManager!

hasParent
	^self parent notNil!

parent
  ^ parent!

parent: aParentObject
  parent := aParentObject.
  permissionManager parent: aParentObject.
  membershipManager parent: aParentObject.! !


!ConferenceManager methodsFor: 'accessing'!

locationsContainer
	^locationsContainer!

groupManager: aGroupManager 
	groupManager := aGroupManager!

userManager: anUserManager
	userManager := anUserManager!

confContainer: aConfContainer
	confContainer := aConfContainer!

locationsContainer: aLocationsContainer
	locationsContainer := aLocationsContainer!

confContainer
	^confContainer!

groupManager
	^groupManager!

userManager
	^userManager! !

!ConferenceManager methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created ConferenceManager"

      super initialize.
	confContainer := ConferenceContainer new initialize.
	userManager := UserManager new initialize.
	groupManager := GroupManager new initialize.
	locationsContainer := LocationsContainer new initialize.
      self addRootUser.
      self addAdminGroup.


	^self!

addRootUser
	"Add user called RootUser into the UserManager" 

	userManager addUser: 'Root' surname: 'administrator' login: 'root' password: self rootPassword email: self rootEmail.!

addAdminGroup
	"Add a Group called Admin into the GroupManager" 

	groupManager addGroup: 'Admin'!

initPermissions
	super initPermissions.
	self permissionManager setPermission: 'View'
		members: (Set with: 'Admin' with: 'Anonymous').
	self permissionManager setPermission: 'Fill Database'
		members: (Set with: 'Admin')!

rootEmail
	"Default email address for the RootUser"

   	^ 'root@nowhere.de'!

rootPassword
	"Default password for the RootUser"

   ^ 'tototo'! !


!RoomsContainer methodsFor: 'mutator'!

deleteRoom: aRoom 
	rooms remove: aRoom!

addRoom: aRoom
	rooms add: aRoom! !

!RoomsContainer methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with: 'Admin' with:'Logged User').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin').
   self permissionManager setPermission: 'Add Room' members: (Set with:'Admin' with:'Logged User').!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

super initialize.
	rooms := Set new.
	self initPermissions.
	^self! !

!RoomsContainer methodsFor: 'accessing'!

getRoomsName
	| roomsName |
	roomsName := Set new.
	rooms do: [:room | roomsName add: room name].
	^roomsName!

rooms
  ^ rooms!

size
	^rooms size!

getRoomWithName: aRoomName
	rooms do: [:room | (room name) = aRoomName ifTrue: [^room]].
	^nil! !


!Article class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!Article methodsFor: 'reporting'!

mailReportToAuthor: lecturer conference: aConference

|theMailBody status|
self reviewerApproved = 1
	ifTrue: [ status := 'APPROVED'. ]
	ifFalse: [ status := 'REJECTED'. ].

theMailBody := 'Dear ' , self user surname , ' ' , self user name , ',

     Your article "' , self title , '" written in regards with the "' , aConference name , '" Conference has been ' , status , '

     Regards, 
' , lecturer surname , ' ' , lecturer name , '.'.

Net.MailMessage newTextPlain
		subject: 'Final Status for Article "' , self title , '"';
		from: lecturer email;
		to: self user email;
		text: theMailBody;
		send! !

!Article methodsFor: 'mutator'!

addComment: aComment
	"adds a Comment to an Article"

	comments addComment: aComment.!

reviewerApprove
	reviewerApproved := true!

modify: anArticle
	"Allows to modify the title and the content of an Article"
	self title: anArticle title.
	self data: anArticle data.
	self keywords: anArticle keywords.!

openADiscussion
	openDiscussion := true!

reviewerDisapprove
"Change the status of the Article to disapproved by the reviewer"
	reviewerApproved := false!

lecturerApprove
	"Change the status of the Article to approved by the lecturer"
  	lecturerApproved := true!

lecturerDisapprove
	"Change the status of the Article to disapproved by the lecturer"
	lecturerApproved := false!

closeADiscussion
	"close a discussion about an Article"

	openDiscussion := false! !

!Article methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created Article."

	super initialize.
	title := nil.
	keywords := KeywordsContainer new initialize.
	keywords sortBlock: [:x :y | x <= y].
	user := nil.
	data := nil.
	comments := CommentContainer new parent: self.
	self initGroups.
	self initPermissions.
	self closeADiscussion.
	self lecturerDisapprove.
	self reviewerDisapprove.
	^self!

initPermissions
      super initPermissions.
      self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User' with:'Anonymous').
      self permissionManager setPermission: 'Modify' members: (Set with:'Admin' with:'Owner').
      self permissionManager setPermission: 'Review' members: (Set with:'Acquire').!

initGroups
   super initGroups.
! !

!Article methodsFor: 'accessing'!

averageRating
	|sumNotes numberNotes avgNote|
	sumNotes:=0.
	numberNotes:=0.
	comments comments do:
		[:aComment |
		numberNotes:=numberNotes+1.
		sumNotes:=sumNotes + aComment rating.
		].
	avgNote := sumNotes/numberNotes.
	^ avgNote.!

comments: aComment
	comments := aComment!

keywords: aSetOfKeywords
	keywords addKeywords: aSetOfKeywords.!

lecturerApproved
	^lecturerApproved!

comments
	^comments!

user: anUser
     self membershipManager setGroupMembers: (Set with: anUser login) groupName: 'Owner'.
	user := anUser.!

validate
	title ifNil: [self validationError: 'You must provide a title for this article.'. self error: 'You must provide a title for this article.'.].
	data ifNil: [self validationError: 'You must provide a text for this article.'. self error: 'You must provide a text for this article.'.].!

user
	^user!

data: anObject
	data := anObject!

keywords
	^keywords!

title: anObject
	title := anObject!

title
	^title!

data
	^data!

reviewerApproved
"return the status of the Article to 'approved' by the reviewer"
  ^reviewerApproved!

openDiscussion
	^openDiscussion! !


!LocationsContainer methodsFor: 'mutator'!

deleteLocation: aLocation 
	locations removeKey: (locations keyAtValue: aLocation)!

addLocation: aLocation 
	| locationAssoc |
	locationAssoc := Association new key: aLocation place value: aLocation.
	locations add: locationAssoc! !

!LocationsContainer methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User' with:'Anonymous').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin').
   self permissionManager setPermission: 'Add Location' members: (Set with:'Admin' with:'Logged User').
   self permissionManager setPermission: 'Delete' members: (Set with:'Owner' with:'Admin').!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	locations := Dictionary new.
	" *** Replace this comment with the appropriate initialization code *** "
	self initPermissions.
	^self! !

!LocationsContainer methodsFor: 'accessing'!

getLocationWithPlace: aLocationPlace
	self getLocationsObjects 
		do: [:location | location place = aLocationPlace ifTrue: [^location]].
	^nil!

getLocations
	"return a Set of locations"

	^locations localBindingNames!

locations
	^locations!

getLocationsObjects
	"return a Set of locations"

	^locations values!

hasLocation
   ^ ((locations isEmpty) not).!

getLocationsObjects: name
	"return a Set of locations"

	^locations values! !


!Talk methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Edit the following to properly initialize instance variables ***"
	article := nil.
	dateTimeBegin := Squeak.DateAndTime new.
	dateTimeEnd := Squeak.DateAndTime new.
	room := nil.
	" *** And replace this comment with additional initialization code *** "
	^self!

initPermissions
      super initPermissions.
      self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User' with:'Anonymous').
      self permissionManager setPermission: 'Delete' members: (Set with: 'Admin' with:'Acquire').! !

!Talk methodsFor: 'accessing'!

dateTimeEnd
   ^ dateTimeEnd!

dateTimeEnd: aDateAndTime
   dateTimeEnd := aDateAndTime!

validate
	dateTimeEnd > dateTimeBegin 
		ifFalse: 
			[self validationError: 'The begin time must stand before the end time.'. self error: 'The begin time must stand before the end time.'.].!

article
	^article!

room
	^room!

room: anObject
	room := anObject!

dateTimeBegin
   ^ dateTimeBegin!

dateTimeBegin: aDateAndTime
   dateTimeBegin := aDateAndTime!

article: anObject
	article := anObject! !


!PermissionManager class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!PermissionManager methodsFor: 'mutator'!

setPermission: aPermission members: aSetOfMembers 
	"aSetOfMembers can contain users and groups"

	| permAssoc |
	(permissionDictionary includesKey: aPermission) 
		ifFalse: 
			[permAssoc := Association new key: aPermission value: aSetOfMembers.
			permissionDictionary add: permAssoc]
		ifTrue: [permissionDictionary at: aPermission put: aSetOfMembers]!

addMemberToPermission: aPermission member: aMember 
	"aMember can be an User or a Group"

	| permAssoc aSetOfPermission |
	(permissionDictionary includesKey: aPermission) 
		ifFalse: 
			[permAssoc := Association new key: aPermission value: (Set with: aMember).
			permissionDictionary add: permAssoc]
		ifTrue: 
			[aSetOfPermission := permissionDictionary at: aPermission.
			aSetOfPermission isEmpty 
				ifTrue: 
					[aSetOfPermission := Set with: aMember.
					permissionDictionary at: aPermission put: aSetOfPermission]
				ifFalse: [aSetOfPermission add: aMember]]!

addPermission: permissionName
"can create new permission" 
| permAssoc |
	(permissionDictionary includesKey: permissionName) 
		ifFalse: 
			[permAssoc := Association new key: permissionName value: #().
			permissionDictionary add: permAssoc]! !

!PermissionManager methodsFor: 'initialize-release'!

initialize

     permissionDictionary := Dictionary new.
	^self! !

!PermissionManager methodsFor: 'accessing'!

membershipManager: aMembershipManager
   membershipManager := aMembershipManager!

permissionDictionary
   ^ permissionDictionary!

renderedObjectName: anObjectName 
    renderedObjectName := anObjectName!

parent
   ^ parent!

membershipManager
  ^ membershipManager!

parent: aParentObject 
	parent := aParentObject!

hasPermission: aPermission memberName: aMemberName 
	| aSetOfMembers |
	(permissionDictionary includesKey: aPermission) 
		ifFalse: [self error: 'Wrong permission name!!']
		ifTrue: 
			[aSetOfMembers := permissionDictionary at: aPermission.
			aSetOfMembers isNil 				
				ifFalse: 
					[aSetOfMembers do: 
							[:member | 
							member = 'Acquire' 
								ifTrue: 
									[self hasParent 
										ifTrue: 
											[^self parent permissionManager hasPermission: aPermission
												memberName: aMemberName]]
								ifFalse: 
									[(membershipManager isGroup: member) 
										ifTrue: 
											[(membershipManager isMemberOfGroup: member userLogin: aMemberName) 
												ifTrue: [^true]]
										ifFalse: [aMemberName = member ifTrue: [^true]]]].
					^false]]!

renderedObjectName 
    ^ renderedObjectName!

hasParent
	^self parent notNil! !


!KeywordsContainer class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!KeywordsContainer methodsFor: 'mutator'!

addKeywords: aSetOfKeywords
  aSetOfKeywords do: [:keyword | self addKeyword: keyword]!

addKeyword: aKeyword 
	(self includes: aKeyword) 
		ifFalse: [aKeyword = '' ifFalse: [self add: aKeyword]]!

removeAll
	firstIndex to: lastIndex do: [:index | self removeIndex: index]! !

!KeywordsContainer methodsFor: 'accessing'!

keywords: aCollectionOfKeywords
   self removeAll.
   aCollectionOfKeywords do: [:keyword | self addKeyword: keyword]! !

!KeywordsContainer methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created instance of Keywords Container"
	super initialize.
	^self! !


!MembershipManager class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!MembershipManager methodsFor: 'mutator'!

setGroupMembers: aSetOfUsers groupName: aGroupName 
	"assigns User to a Group"

      | memberAssoc |
      (groupDictionary includesKey: aGroupName)
      ifFalse: [  memberAssoc := Association new key: aGroupName value: aSetOfUsers.
	              groupDictionary add: memberAssoc.
                 ]
      ifTrue: 
               [
                   groupDictionary at: aGroupName put: aSetOfUsers.
               ]!

addGroupMembers: aGroupName 


	| memberAssoc |
	(groupDictionary includesKey: aGroupName) 
		ifFalse: 
			[memberAssoc := Association new key: aGroupName value: #().
			groupDictionary add: memberAssoc]!

addMemberToGroup: aUser group: aGroupName 
	"Add User to a Group"

	| memberAssoc aSetOfMember |
	(groupDictionary includesKey: aGroupName) 
		ifFalse: 
			[memberAssoc := Association new key: aGroupName value: aUser.
			groupDictionary add: memberAssoc]
		ifTrue: 
			[aSetOfMember := groupDictionary at: aGroupName.
			(aSetOfMember isEmpty) 
				ifTrue: [aSetOfMember := (Set with: aUser). groupDictionary at: aGroupName put: aSetOfMember. ]
				ifFalse: [aSetOfMember add: aUser]]! !

!MembershipManager methodsFor: 'initialize-release'!

initialize
	
	groupDictionary := Dictionary new.

      self addGroupMembers: 'Logged User'.
      self addGroupMembers: 'Anonymous'.

	^self! !

!MembershipManager methodsFor: 'accessing'!

getGroups
  ^ groupDictionary keys!

isMemberOfGroup: aGroupName userLogin: anUserLogin 
	| aSetOfMembers |
	(groupDictionary includesKey: aGroupName) 
		ifFalse: 
			[self hasParent 
				ifTrue: 
					[self parent membershipManager isMemberOfGroup: aGroupName
						userLogin: anUserLogin]
				ifFalse: [^false]]
		ifTrue: 
			[aGroupName = 'Logged User' 
				ifTrue: [^((anUserLogin isNil) not)]
				ifFalse: 
					[aGroupName = 'Anonymous' & (anUserLogin isNil) 
						ifTrue: [^true]
						ifFalse: 
							[aSetOfMembers := groupDictionary at: aGroupName.
							aSetOfMembers isNil 
								ifTrue: [^false]
								ifFalse: [^aSetOfMembers includes: anUserLogin]]]]!

groupDictionary
	^groupDictionary!

members
   ^ groupDictionary values!

parent
   ^ parent!

isGroup: aGroupName
   ^ groupDictionary includesKey: aGroupName!

parent: aParentObject 
	parent := aParentObject!

hasParent
	^self parent notNil!

getVisibleGroups
	| listOfGroups |
	listOfGroups := groupDictionary keys.
	listOfGroups
		remove: 'Anonymous';
		remove: 'Logged User'.
	^listOfGroups! !


!ConferenceContainer class methodsFor: 'instance creation'!

initialize
	^self! !


!ConferenceContainer methodsFor: 'mutator'!

deleteConference: aConference
"Remove a Conference from the ConferenceContainer"

	conferences removeKey: (conferences keyAtValue: aConference).!

addConference: aConference 
	"Add a Conference to the ConferenceContainer"

	| conferenceAssoc newId |

	newId := self conferences size + 1.
	conferenceAssoc := Association new key: newId value: aConference.
	conferences add: conferenceAssoc!

addSharedKeyword: aSharedKeyword 
	"Add a keyword available to all the Conferences"
sharedKeywords addKeyword: aSharedKeyword.! !

!ConferenceContainer methodsFor: 'initialize-release'!

initPermissions
	super initPermissions.
	self permissionManager setPermission: 'View'
		members: (Set 
				with: 'Admin'
				with: 'Logged User'
				with: 'Anonymous').
	self permissionManager setPermission: 'Modify'
		members: (Set with: 'Admin' with: 'Logged User').
	self permissionManager setPermission: 'Add Conference'
		members: (Set with: 'Admin' with: 'Logged User')!

initialize
	"Initialize a newly created conferenceContainer"

	super initialize.
	conferences := Dictionary new.
	sharedKeywords := KeywordsContainer new.
	sharedKeywords sortBlock: [:x :y | x <= y].
	self initPermissions.
	^self! !

!ConferenceContainer methodsFor: 'accessing'!

hasConference
   ^ ((conferences isEmpty) not).!

sharedKeywords
	^sharedKeywords!

getConferencesId
	"return a Set of conferences ids"

	^conferences keys!

sharedKeywords: aSetOfSharedKeywords
	sharedKeywords:= aSetOfSharedKeywords.!

conferences
	^conferences!

getConference: id
  "get the conference by its id"
  ^conferences at: id.!

getConferencesObjects
	"return a Set of conferences"

	^conferences values!

size
  ^ conferences size! !


!Location methodsFor: 'mutator'!

modify: aLocation 
	"Allow to modify a location"

	self place: aLocation place.
	self address: aLocation address.! !

!Location methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User' with:'Anonymous').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin' with:'Owner').
   self permissionManager setPermission: 'Delete' members: (Set with:'Owner' with:'Admin').!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Edit the following to properly initialize instance variables ***"
	place := nil.
	address := nil.
	roomsContainer := RoomsContainer new initialize.
	" *** And replace this comment with additional initialization code *** "
	^self! !

!Location methodsFor: 'accessing'!

address: anObject
	address := anObject!

validate
	place ifNil: [self validationError: 'You must provide a place for this location.'. self error: 'You must provide a place for this location.'.].
	address ifNil: [self validationError: 'You must provide an address for this location.'. self error: 'You must provide an address for this location.'.].!

place: anObject
	place := anObject!

rooms
	^roomsContainer!

address
	^address!

place
	^place! !


!Schedule methodsFor: 'mutator'!

deleteTalk: aTalk
    talks remove: aTalk!

addTalk: aTalk 
	aTalk parent: self.
	talks add: aTalk! !

!Schedule methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with: 'Admin' with:'Logged User').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin' with:'Lecturers').
   self permissionManager setPermission: 'Add Talk' members: (Set with:'Admin' with:'Lecturers').!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	talks := (SortedCollection new initialize) sortBlock: [:x :y | x dateTimeBegin <= y dateTimeBegin].
	^self! !

!Schedule methodsFor: 'accessing'!

getTalksWithRoom: roomName 
 | searchedTalks |
	searchedTalks := Set new.
	talks do: [:talk | talk room = roomName ifTrue: [searchedTalks add: talk]].
	^searchedTalks.!

articleAssigned
	| listOfArticles |
	listOfArticles := Set new.
	talks do: [:talk | listOfArticles add: talk article].
	^listOfArticles!

talks
   ^ talks! !


!CommentContainer class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!CommentContainer methodsFor: 'mutator'!

addComment: aComment
	"Add a Comment about an Article into the commentContainer of this Article" 
      aComment parent: self.
	self comments add: aComment.!

deleteComment: aComment
"Delete a Comment about an Article into the commentContainer of this Article"

	comments remove: (aComment).! !

!CommentContainer methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin').
   self permissionManager setPermission: 'Add Comment' members: (Set with:'Admin' with:'Logged User').!

initialize
	"Initialize a newly created CommentContainer of an Article"

      super initialize.
      comments := Set new.
      self initPermissions.

	^self! !

!CommentContainer methodsFor: 'accessing'!

hasComment
   ^ ((comments isEmpty) not)!

comments
   ^ comments!

comments: aSetOfComments
   comments := aSetOfComments!

size
  ^ comments size! !


!Room methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with: 'Admin' with:'Logged User').
   self permissionManager setPermission: 'Delete' members: (Set with:'Admin' with:'Owner').!

initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Edit the following to properly initialize instance variables ***"
	name := nil.
	capacity := nil.
	" *** And replace this comment with additional initialization code *** "
	^self! !

!Room methodsFor: 'accessing'!

validate
	name ifNil: [self validationError: 'Please enter a name for the room.'. self error: 'Please enter a name for the room.'.].
	capacity ifNil: [self validationError: 'Please enter the room`s capacity.'. self error: 'Please enter the room`s capacity.'.].!

capacity: anObject
	capacity := anObject!

name: anObject
	name := anObject!

name
	^name!

capacity
	^capacity! !


!UserManager class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!UserManager methodsFor: 'mutator'!

addUser: aName surname: aSurname login: aLogin password: aPassword email: anEmail
	" add user from parameter passed"

	| aUser userAssoc |
	aUser := User new initialize.
	aUser name: aName.
	aUser surname: aSurname.
	aUser login: aLogin.
      aUser password: aPassword.
      aUser email: anEmail.

	userAssoc := Association new key: aLogin value: aUser.
	usersDictionary add: userAssoc.!

addUser: anUser 
	| userAssoc |
	userAssoc := Association new key: anUser login value: anUser.
	usersDictionary add: userAssoc.!

addSharedSkill: aSharedSkill 
	"Add a skill available to all the users"

	sharedSkills addKeyword: aSharedSkill!

deleteUser: anUser
	usersDictionary removeKey: (usersDictionary keyAtValue: anUser).!

modifyUser: anUser 
anUser modify: anUser.! !

!UserManager methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created UserManager"

    super initialize.
    usersDictionary := Dictionary new.

    sharedSkills := KeywordsContainer new.
    sharedSkills sortBlock: [:x :y | x <= y].

    self initPermissions.
	
	^self!

initPermissions
	super initPermissions.
	self permissionManager setPermission: 'View' members: (Set with: 'Admin').
	self permissionManager setPermission: 'Modify' members: (Set with: 'Admin').
	self permissionManager setPermission: 'Add User'
		members: (Set with: 'Admin' with: 'Anonymous')! !

!UserManager methodsFor: 'accessing'!

getUserLogins
	"return a Set of user logins"

	^usersDictionary localBindingNames!

size
	^usersDictionary size!

usersDictionary
  "return the dictionary containing all users"
  ^ usersDictionary!

sharedSkills
  ^ sharedSkills!

hasLogin: login
  ^ (usersDictionary includesKey: login)!

getUserObjects
	"return a Set of users"

	^usersDictionary values!

getUser: userLogin
  "get the user by its login"
  ^ usersDictionary at: userLogin.!

sharedSkills: aSetOfSharedSkills
	sharedSkills:= aSetOfSharedSkills.! !


!Comment class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!Comment methodsFor: 'accessing'!

validate
	text ifNil: [self validationError: 'You must enter a text for your comment.'. self error: 'You must enter a text for your comment.'.]!

rating: aNumber 
	rating := aNumber!

text
	^text!

user: anUserLogin 
	self membershipManager setGroupMembers: (Set with: anUserLogin)
		groupName: 'Owner'.
	user := anUserLogin.!

user
	^user!

text: aString
	text := aString!

rating
	^rating! !

!Comment methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created Comment about an Article"

      super initialize.
	user := nil.
	rating := nil.
	text := nil.
      self initGroups.
      self initPermissions.

	^self!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin' with: 'Owner').!

initGroups
	super initGroups.
	self membershipManager addGroupMembers: 'Owner'! !


!GroupManager class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!GroupManager methodsFor: 'mutator'!

addGroup:aGroupName
	"Add a new group into the GroupManager"

	| aGroup groupAssoc |
	aGroup := Group new name: aGroupName.
	groupAssoc := Association new key: aGroupName value: aGroup.
	groupDictionary add: groupAssoc.! !

!GroupManager methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created GroupManager"

      super initialize.
	groupDictionary := Dictionary new.
	^self!

initPermissions
	super initPermissions.
	self permissionManager setPermission: 'View' members: (Set with: 'Admin').
	self permissionManager setPermission: 'Modify' members: (Set with: 'Admin').
	self permissionManager setPermission: 'Add Group'
		members: (Set with: 'Admin')! !

!GroupManager methodsFor: 'accessing'!

groupDictionary	
	^groupDictionary!

getGroups
	^groupDictionary values!

size
	^groupDictionary size!

hasGroup:aGroupName
"return if the Group name exist"

	^(groupDictionary includesKey: aGroupName)!

groupDictionary: aDictionaryOfGroups
	groupDictionary := aDictionaryOfGroups! !


!User class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!User methodsFor: 'mutator'!

modify: aUser 
	"Allow to modify a User"
	self name: aUser name.
	self surname: aUser surname.
	self email: aUser email.
	self skills: aUser skills.
	self name: aUser name.!

addSkill: aString
	"Add a Skill for an User"

	skills add: aString! !

!User methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created User"

      super initialize.
      skills := KeywordsContainer new initialize.
      skills sortBlock: [:x :y | x <= y].


      self initPermissions.

	^self!

initPermissions
      super initPermissions.
      self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Owner').
      self permissionManager setPermission: 'Modify' members: (Set with: 'Admin' with:'Owner').! !

!User methodsFor: 'accessing'!

password: aString
  "set the password of the user"
  password := aString!

validate
	name ifNil: [self validationError: 'You must provide your name.'. self error: 'You must provide your name.'.].
	surname ifNil: [self validationError: 'You must provide your surname.'. self error: 'You must provide your surname.'.].
	login ifNil: [self validationError: 'You must provide a login.'. self error: 'You must provide a login.'.].
	password = '' 
		ifTrue: [self validationError: 'You must provide a password.'. self error: 'You must provide a password.'.].
	email ifNil: [self validationError: 'You must provide an email address.'. self error: 'You must provide an email address.'.]!

password 
  "return the password of the user"
  ^ password!

name
  "return the name of the user"
  ^ name!

login
  " return the login of the user"
  ^ login!

email: aString
  " set the email address of the user"
  email := aString!

surname: aString
	"set the surname of the user"

	surname := aString!

surname
	"return the surname of the user"

	^surname!

skills
	^ skills!

skills: aSetOfKeywords
   skills addKeywords:  aSetOfKeywords.!

name: aString
  "set the name of the user"
  name := aString!

email
  "return the mail address of the user"
  ^ email!

login: aString
  " set the login of the user"
  login := aString! !


!Group class methodsFor: 'instance creation'!

new
	"Answer a newly created and initialized instance."

	^super new initialize! !


!Group methodsFor: 'accessing'!

validate
	name ifNil: [self validationError: 'You must provide a name.'. self error: 'You must provide a name.'.].!

name
	^name!

name: aString
	name := aString! !

!Group methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created Group"
      super initialize.
	name := nil.

	^self!

initPermissions
      super initPermissions.
      self permissionManager setPermission: 'View' members: (Set with:'Admin').
      self permissionManager setPermission: 'Modify' members: (Set with:'Admin').! !


!Conference methodsFor: 'reporting'!

mailReportToAll
self articleContainer articles do:
	[:anArticle|
		anArticle mailReportToAuthor: (self userManager getUser: lecturer) conference: self.
	].
self setMailSent.! !

!Conference methodsFor: 'mutator'!

modify: aConference 
	"Allow to modify a Conference"

	self name: aConference name.
	self keywords: aConference keywords.
	self articleContainer: aConference articleContainer.
	self articleDeadline: aConference articleDeadline.
	self commentsDeadline: aConference commentsDeadline.
	self notificationDeadline: aConference notificationDeadline.
	self beginDate: aConference beginDate.
	self endDate: aConference endDate.
	self expirationDate: aConference expirationDate.
	self lecturer: aConference lecturer!

addKeyword: aKeyword 
	"Add keywords for a Conference"

	keywords addKeyword: aKeyword!

setMailSent
	mailHasBeenSent := 1.! !

!Conference methodsFor: 'initialize-release'!

initPermissions
   super initPermissions.
   self permissionManager setPermission: 'View' members: (Set with:'Admin' with:'Logged User' with:'Anonymous').
   self permissionManager setPermission: 'Modify' members: (Set with:'Admin' with:'Lecturers').
   self permissionManager setPermission: 'Mail article author' members: (Set with: 'Lecturers').
   self permissionManager setPermission: 'Review' members: (Set with: 'Reviewer').
   self permissionManager setPermission: 'Delete' members: (Set with:'Admin' with:'Lecturers').
   self permissionManager setPermission: 'View Security Manager' members: (Set with:'Admin' with: 'Lecturers').!

initGroups
   super initGroups.
   self membershipManager addGroupMembers: 'Reviewer'.
   self membershipManager addGroupMembers: 'Lecturers'.!

initialize
	"Initialize a newly created Conference"
    
	super initialize.
	name := nil.
	mailHasBeenSent := 0.
      keywords := KeywordsContainer new initialize.
      keywords sortBlock: [:x :y | x <= y].

	articleContainer := ArticleContainer new initialize parent: self.
      schedule := Schedule new initialize.
     self initGroups.
      self initPermissions.
 
	^self! !

!Conference methodsFor: 'accessing'!

commentsDeadline: aDate
  commentsDeadline := aDate.!

endDate
  ^endDate!

location: aLocation
	location := aLocation!

notificationDeadline: aDate
  notificationDeadline := aDate.!

name: aString
	name := aString!

schedule
   ^ schedule!

beginDate
  ^beginDate!

articleDeadline: aDate
  articleDeadline := aDate.!

userManager
	^userManager!

keywords: aSetOfKeywords
   keywords addKeywords: aSetOfKeywords.!

articleContainer: anArticleContainer
   articleContainer := anArticleContainer!

validate
	name ifNil: [self validationError: 'You must provide the name of the conference.'. self error: 'You must provide the name of the conference.'.].
	Date today < articleDeadline 
		ifFalse: 
			[self 
				validationError: 'You must provide a correct article deadline with the current date.'. self error: 'You must provide a correct article deadline with the current date.'.].
	articleDeadline < commentsDeadline 
		ifFalse: 
			[articleDeadline = commentsDeadline 
				ifFalse: 
					[self 
						validationError: 'You must provide a correct article deadline with the comments deadline.'. self error: 'You must provide a correct article deadline with the comments deadline.'.]].
	commentsDeadline < notificationDeadline 
		ifFalse: 
			[commentsDeadline = notificationDeadline 
				ifFalse: 
					[self 
						validationError: 'You must provide a correct comments deadline with the notification deadline.'. self error: 'You must provide a correct comments deadline with the notification deadline.'.]].
	notificationDeadline < beginDate 
		ifFalse: 
			[notificationDeadline = beginDate 
				ifFalse: 
					[self 
						validationError: 'You must provide a correct notification deadline with the begin date.'. self error: 'You must provide a correct notification deadline with the begin date.'.]].
	beginDate < endDate 
		ifFalse: 
			[beginDate = endDate 
				ifFalse: 
					[self validationError: 'You must provide a correct begin date with the end date.'. self error: 'You must provide a correct begin date with the end date.'.]].
	lecturer ifNil: [self validationError: 'You must provide the name of the lecturer.'. self error: 'You must provide the name of the lecturer.'.]!

endDate: aDate
  endDate := aDate.!

location
  ^location!

name
	^name!

lecturer
  ^lecturer!

articleDeadline
  ^articleDeadline!

keywords
  ^ keywords!

lecturer: anUserLogin 
	self membershipManager 
		setGroupMembers: ((Set with: anUserLogin with: 'root'))
		groupName: 'Lecturers'.
	lecturer := anUserLogin!

expirationDate: aDate
  expirationDate := aDate.!

mailHasBeenSent
 ^mailHasBeenSent!

expirationDate
  ^expirationDate!

beginDate: aDate
  beginDate := aDate.!

commentsDeadline
 ^commentsDeadline!

notificationDeadline
  ^notificationDeadline!

articleContainer
   ^ articleContainer!

userManager: anUserManager
	userManager := anUserManager.! !


!ArticleContainer methodsFor: 'mutator'!

addArticle: anArticle
	"Add an Article to the ArticleContainer"
	anArticle parent: self.
	articles add: anArticle.!

deleteArticle: anArticle
"Remove an Article to the ArticleContainer"

	articles remove: (anArticle).! !

!ArticleContainer methodsFor: 'initialize-release'!

initialize
	"Initialize a newly created ArticleContainer for a Conference"

	super initialize.
	articles := SortedCollection new.
	articles sortBlock: [:x :y | x title < y title].
	self initPermissions.
	^self!

initPermissions
	"Initialize the permissions of ...."

	super initPermissions.
	self permissionManager setPermission: 'View'
		members: (Set 
				with: 'Admin'
				with: 'Logged User'
				with: 'Anonymous').
	self permissionManager setPermission: 'Modify' members: (Set with: 'Admin').
	self permissionManager setPermission: 'Add Article'
		members: (Set with: 'Admin' with: 'Logged User').
	self permissionManager setPermission: 'Review'
		members: (Set with: 'Acquire')! !

!ArticleContainer methodsFor: 'accessing'!

approvedArticles
	| approved |
	approved := Set withAll: articles.
	approved 
		do: [:article | article reviewerApproved ifFalse: [approved remove: article]].
	^approved!

articlesTitle
	| articlesTitle |
	articlesTitle := Set new.
      articles do: [:article | articlesTitle add: (article title)].
       ^ articlesTitle!

articles: anObject
	articles := anObject!

getArticleWithTitle: articleTitle 
	articles do: [:article | article title = articleTitle ifTrue: [^article]].
	^nil!

articlesTitle: aSetOfArticle
	| articlesTitle |
	articlesTitle := Set new.
      aSetOfArticle do: [:article | articlesTitle add: (article title)].
       ^ articlesTitle!

hasArticle
	^((articles isEmpty) not).!

size
	^articles size!

articles
	^articles! !



#{ConferenceContainer} initialize!

Generated by
GNU enscript 1.6.4.

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: