gmAdd {gmDatabase}R Documentation

Adding and updating objects in a geometallurgical database.

Description

gmAdd adds a new object to a geometallurgical database. Its attributes can be set and updated with gmSet

Usage

gmAdd(where, what, data, rg=getOption("defaultRightsGroup"), EXPR=substitute(where), 
  envir=parent.frame(), db=getOption("gmDB"), force=FALSE)
gmSet(where, data, varID=NULL, childs=NULL, members=NULL,EXPR=substitute(where), 
  envir=parent.frame(), db=getOption("gmDB"), update=TRUE)

Arguments

where

an expression specifying where in the hierarchical structure of the database the new object(s) should be added.

what

specifies the variable type of the new object(s). Apart from an R expression of an SQL query or a gmExpr, a ID from the database is possible, too.

data

list or data frame giving attributes for the new object(s).

rg

states the id of the rights groups this object will belongs to.

varID

the variable ID of the objects to be updated

childs

a data frame containing the class member of the object to be updated

members

a vector containing the names of the class members of what, which will be updated

EXPR

the quoted version of where.

envir

defines the environment used for evaluation of where.

db

defines the database, on which the query will be run.

force

logical: if FALSE, the case of missing required class members results in an abortion, otherwise only warnings are printed.

update

logical: if TRUE, set objects will be updated instead of adding new entries.

Details

gmAdd adds one or more new objects of the specified variable name to a geometallurgical database. The number of new objects is determined by data. This is a list or data frame stating values for the class members of each new object. If force=TRUE missing required class members are ignored and a warning is given. If force=FALSE the insert is aborded in the case of missing required members with a corresponding error message. If no rights group is given the object will not be linked to the default rights group. If that is not explicitly set by gmDefaultRightsGroup the new object will not be linked to any rights group. Therefore it will be accessible by everyone.

For the actual insertion of the values of the members, the function gmSet is used. If a member given in data is already set for this object, then the database is being updated. Otherwise this attribute is added. Attributes which are not allowed for this object result in an abortion and an error message.

If gmSet is used outside gmAdd the argmuments varID, childs and members may be missing and therefore set to NULL. Then they are queried prior to the insertion. This setting is used to determine, if gmSet is called by gmAdd. If data contains a set object, setting the argument update to TRUE prohibits updating this member. Instead an additional entry is added.

If gmSet is called by gmAdd and a creationTime is missing in data, gmSet adds the actual time instead. Since that for variables of the type set more than one entry is permitted, you have the possibility of updating the entry or adding a new reference by setting update=FALSE. If there is already more than one entry, updating is not permitted.

Value

gmAdd returns the gmID of the first added object.

Author(s)

K. Gerald van den Boogaart, S. Matos Camacho

See Also

gmRead, gmExpr

Examples

## Not run: 
  gmAdd(root,"project",list(gmTitle="sunny thursday", gmCreator=3))
  gmSet(root$project[gmTitle=="sunny thursday"], list(gmName="something"))
  
## End(Not run)

[Package gmDatabase version 0.5.0 Index]