Learn R Programming

gmDatabase (version 0.5.0)

gmCreateClass: Providing new classes and adding new users, rights groups, usergroups, etc.

Description

For working with a (geometallurgical) database you need at least some users, rights groups to manage their access rights, or classes/variables, you want to store the data.

Usage

gmCreateClass(name, type, description, parent="gmObject", envir=parent.frame(), db=getOption("gmDB")) gmAddMembers(class, members, required, envir=parent.frame(), db=getOption("gmDB")) gmCreateRightsGroup(rightsGroup, envir=parent.frame(), db=getOption("gmDB")) gmCreateUserGroup(userGroup, envir=parent.frame(), db=getOption("gmDB")) gmSetRights(userGroup, rightsGroup, write=TRUE, read=TRUE, envir=parent.frame(), db=getOption("gmDB")) gmAddUserToGroup(user, userGroup, envir=parent.frame(), db=getOption("gmDB")) gmSetRightsGroup(object, rightsGroup, envir=parent.frame(), db=getOption("gmDB")) gmCreateUser(user, password, userGroups, envir=parent.frame(), db=getOption("gmDB")) gmDefaultRightsGroup(rightsGroup, db=getOption("gmDB"))

Arguments

name
The name of the new class, which shall be created.
type
The type of the new class.
description
A short description of the calss and what it is for.
parent
The super class of the new one.
class
The name of the class to which the members shall be added.
members
The names of the new class members.
required
A logical. If TRUE this member has to be initialised, when an instance of the object is added to the database.
rightsGroup
The name or, if it refers an existing one, ID of the rights group.
userGroup
The name or, if it refers an existing one, ID of the usergroup
user
The username oder ID of the user, who shall be added.
write
A logical. If TRUE the stated usergroup is granted writing rights.
read
A logical. If TRUE the stated usergroup is granted reading rights.
object
An ID or gmExpr of the object, for that the rights group shall be determined.
password
The password of the new user.
userGroups
The usergroups the new user shall be part of.
envir
defines the environment used for evaluation of the other arguments.
db
A database connection object as returned by gmConnectServer.

Value

and gmCreateUserGroup return the gmID of this object.

Details

gmCreateClass allows the suer to add a new variable/class to the database. If set is given a type, the new class will be inferred from parent, which is gmObject by default.

gmAddMembers allows to add classes/variable to other classes. The option required determines, if this member must be initialised during construction of an instance of class.

gmCreateRightsGroup and gmCreateUserGroup create new rights or user groups. A rights group contains the sets readers and writers, consisting of usergroups, which determine, who is allowed to access or change an object. The rights group of an object can be set with gmSetRights after the initialisation of the object.

gmCreateUser is for creation of a new user. You may add this new user to the appropriate usergroups using gmAddUserToGroup.

During object initialisation using gmAdd the arguments rg can give the needed rights group. If is not given, a default value is used. This can be set by gmDefaultRightsGroup.

See Also

gmConnectServer

Examples

Run this code
## Not run: 
# gmConnectServer(MySQL(), host="myServer.mydomain.edu", user="mysqlUser",
#   passwd="mysqlPassword", dbname="myDB")
# 
# rg = gmCreateRightsGroup("Protected")
# ug = gmCreateUserGroup("Admins")
# gmSetRights("Admins","Protected",read=TRUE,write=TRUE)
# gmAddUserToGroup("admin","Admins")
# 
# gmSetRightsGroup(rg,"Protected")
# gmSetRightsGroup(ug,"Protected")
# 
# rg = gmCreateRightsGroup("general")
# ug = gmCreateUserGroup("users")
# gmSetRightsGroup(c(rg,ug),"Protected")
# 
# gmAddUserToGroup("admin","users")
# gmSetRights("users", "general", read=TRUE, write=TRUE)
# 
# gmCreateUser("myuser","mypassword",c("users"))
# gmCreateUser(userGroups=c("users"))
# gmDisconnectServer()
# 
# gmConnectDB(server="myServer.mydomain.edu",user="mysqlUser",passwd="mysqlPassword")
# gmDefaultRightsGroup("general")
# 
# gmListVariables()
# 
# gmCreateClass("sample","set","a material sample",parent="gmObject")
# gmAddMembers("root","sample", required=FALSE)
# gmClassMembers(var="sample")
# gmAdd(root,"sample",data.frame(gmName="Sample1"))
# 
# gmDisconnectServer()
# ## End(Not run)

Run the code above in your browser using DataLab