module Admin;
from Databases import Name, FirstName, MiddleName, LastName, Password;
export AdminDB, Username, Server;
object AdminDB is Admin*
description: (* An AdminDB contains zero or more administrators.
*);
end Administrator;
object Admin is
components: AdminTitle and name:Name
and us:Username and Password;
description: (* An administrator is anyone who can edit a schedule.
*);
end Admin;
object AdminTitle is string
description: (* AdminTitle is a free-form string.
*);
end AdminTitle;
object Username is string
description: (* Uniquely identifies each administrator.
*);
end Username;
operation NewAdmin is
inputs: adb:AdminDB, admin:Admin;
outputs: adb':AdminDB;
description: (* This operation adds a new administrator to the admin database. *);
precondition:
(*
*There is no administrator in the AdminDB with the same username as the administrator to be added.
*)
(not(exists (admin' in adb)(admin'.us = admin.us) ));
postcondition:
(*
* The administrator is in the outputted adminDB.
*)
adb' = adb + admin;
end NewAdmin;
operation EditAdmin is
inputs: adb:AdminDB, admin:Admin;
outputs: adb':AdminDB;
description: (* This operation edits an administrator in the admin database.*);
precondition: (*None Yet*);
postcondition:
(*
* The administrator is in the outputted AdminDB.
*)
adb' = adb + admin;
end EditAdmin;
operation DeleteAdmin is
inputs: adb:AdminDB, admin:Admin;
outputs: adb':AdminDB;
description: (* This operation deletes an administrator in the admin database. *);
precondition:
(*
* The given administrator is in the inputted AdminDB.
*)
admin in adb;
postcondition:
(*
* An administrator is in the output db if and only if it is not the
* existing administrator to be deleted and it is in the input db.
*)
(forall (admin':Admin)
(admin' in adb') iff ((admin' != admin) and (admin' in adb)));
end DeleteAdmin;
--server
object Server is
components: loc:FilePath and us:Username and pw:Password and sp:SavePassword;
description: (* Server contains the location where the master workspace is stored. *);
operations: SetServer;
end Server;
object FilePath is string
description: (* Location is the address or machine name and path of the server. *);
end Location;
object SavePassword is boolean
description: (* if(SavePassword) then save the Username and Password else do not save them. *);
end SavePassword;
operation SetServer is
inputs: server:Server;
outputs: server':Server;
description: (* Sets the server path for the master workspace. *);
precondition: (* None *);
postcondition:
(*
* The Location and possibly the Username and Password are outputted to Server.
*)
server'.loc = server.loc and
server'.sp = server.sp and
if (server.sp) then (
server'.us = server.us and
server'.pw = server.pw);
end SetServer;
end Admin;
Prev: schedule rsl | Next: [none] | Up: spec | Top: index