BiodbEntryField: A class for describing an entry field.

BiodbEntryFieldR Documentation

A class for describing an entry field.

Description

A class for describing an entry field.

A class for describing an entry field.

Details

This class is used by BiodbEntryFields for storing field characteristics, and returning them through the get() method. The constructor is not meant to be used, but for development purposes the constructor's parameters are nevertheless described in the Fields section.

The constructor accepts the following arguments:

name: The name of the field.

alias: A character vector containing zero or more aliases for the field.

type: A type describing the field. One of: "mass", "name" or "id". Optional.

class: The class of the field. One of: "character", "integer", "double", "logical", "object", "data.frame".

card: The cardinality of the field: either "1" or "*".

forbids.duplicates: If set to TRUE, the field forbids duplicated values.

description: A description of the field.

allowed.values: The values authorized for the field.

lower.case: Set to TRUE if you want all values set to the field to be forced to lower case.

case.insensitive: Set to TRUE of you want the field to ignore case when checking a value.

computable.from: The Biodb ID of a database, from which this field can be computed.

virtual: If set to TRUE, the field is computed from other fields, and thus cannot be modified.

virtual.group.by.type: For a virtual field of class data.frame, this indicates to gather all fields of the specified type to build a data frame.

Methods

Public methods


Method new()

New instance initializer. This class must not be instantiated directly. Instead, you access the instances of this class through the BiodbEntryFields instance that you get from the BiodbMain instance.

Usage
BiodbEntryField$new(
  parent,
  name,
  alias = NA_character_,
  type = NA_character_,
  class = c("character", "integer", "double", "logical", "object", "data.frame"),
  card = c("one", "many"),
  forbids.duplicates = FALSE,
  description = NA_character_,
  allowed.values = NULL,
  lower.case = FALSE,
  case.insensitive = FALSE,
  computable.from = NULL,
  virtual = FALSE,
  virtual.group.by.type = NULL,
  dataFrameGroup = NA_character_
)
Arguments
parent

The BiodbEntryFields parent instance.

name

The field name.

alias

The field aliases as a character vector.

type

The field type.

class

The field class.

card

The field cardinality.

forbids.duplicates

Set to TRUE to forbid duplicated values.

description

The field description.

allowed.values

Restrict possible values to a set of allowed values.

lower.case

All values will be converted to lower case.

case.insensitive

Comparison will be made case insensitive for this field.

computable.from

A list of databases from which to compute automatically the value of this field.

virtual

Set to TRUE if this field is virtual.

virtual.group.by.type

In case of a virtual field, set the type of fields to group together into a data frame.

dataFrameGroup

The data frame group.

Returns

Nothing.


Method getName()

Gets the name.

Usage
BiodbEntryField$getName()
Returns

The name of this field.


Method getType()

Gets field's type.

Usage
BiodbEntryField$getType()
Returns

The type of this field.


Method isOfType()

Tests if this field is of the specified type.

Usage
BiodbEntryField$isOfType(type)
Arguments
type

The type.

Returns

TRUE if this field is of the specified type, FALSE otherwise.


Method getDescription()

Get field's description.

Usage
BiodbEntryField$getDescription()
Returns

The description of this field.


Method hasAliases()

Tests if this field has aliases.

Usage
BiodbEntryField$hasAliases()
Returns

TRUE if this entry field defines aliases, FALSE otherwise.


Method getAliases()

Get aliases.

Usage
BiodbEntryField$getAliases()
Returns

The list of aliases if some are defined, otherwise returns NULL."


Method addAlias()

Adds an alias to the list of aliases.

Usage
BiodbEntryField$addAlias(alias)
Arguments
alias

The name of a valid alias.

Returns

Nothing.


Method removeAlias()

Removes an alias from the list of aliases.

Usage
BiodbEntryField$removeAlias(alias)
Arguments
alias

The name of a valid alias.

Returns

Nothing.


Method getAllNames()

Gets all names.

Usage
BiodbEntryField$getAllNames()
Returns

The list of all names (main name and aliases).


Method isComputable()

Tests if this field is computable from another field or another database.

Usage
BiodbEntryField$isComputable()
Returns

TRUE if the field is computable, FALSE otherwise.


Method getComputableFrom()

Get the list of connectors that can be used to compute this field.

Usage
BiodbEntryField$getComputableFrom()
Returns

A list of list objects. Each list object contains the name of the database from which the field is computable.


Method getDataFrameGroup()

Gets the defined data frame group, if any.

Usage
BiodbEntryField$getDataFrameGroup()
Returns

The data frame group, as a character value.


Method isComputableFrom()

Gets the ID of the database from which this field can be computed.

Usage
BiodbEntryField$isComputableFrom()
Returns

The list of databases where to find this field's value.


Method addComputableFrom()

Adds a directive from the list of computableFrom.

Usage
BiodbEntryField$addComputableFrom(directive)
Arguments
directive

A valid \"computable from\" directive.

Returns

Nothing.


Method removeComputableFrom()

Removes a directive from the list of computableFrom.

Usage
BiodbEntryField$removeComputableFrom(directive)
Arguments
directive

A valid \"computable from\" directive.

Returns

Nothing.


Method correctValue()

Corrects a value so it is compatible with this field.

Usage
BiodbEntryField$correctValue(value)
Arguments
value

A value.

Returns

The corrected value.


Method isEnumerate()

Tests if this field is an enumerate type (i.e.: it defines allowed values).

Usage
BiodbEntryField$isEnumerate()
Returns

TRUE if this field defines some allowed values, FALSE otherwise.


Method isVirtual()

Tests if this field is a virtual field.

Usage
BiodbEntryField$isVirtual()
Returns

TRUE if this field is virtual, FALSE otherwise.


Method getVirtualGroupByType()

Gets type for grouping field values when building a virtual data frame.

Usage
BiodbEntryField$getVirtualGroupByType()
Returns

The type, as a character value.


Method getAllowedValues()

Gets allowed values.

Usage
BiodbEntryField$getAllowedValues(value = NULL)
Arguments
value

If this parameter is set to particular allowed values, then the method returns a list of synonyms for this value (if any).

Returns

A character vector containing all allowed values.


Method addAllowedValue()

Adds an allowed value, as a synonym to already an existing value. Note that not all enumerate fields accept synonyms.

Usage
BiodbEntryField$addAllowedValue(key, value)
Arguments
key

The key associated with the value (i.e.: the key is the main name of an allowed value).

value

The new value to add.

Returns

Nothing.


Method checkValue()

Checks if a value is correct. Fails if value is incorrect.

Usage
BiodbEntryField$checkValue(value)
Arguments
value

The value to check.

Returns

Nothing.


Method hasCardOne()

Tests if this field has a cardinality of one.

Usage
BiodbEntryField$hasCardOne()
Returns

TRUE if the cardinality of this field is one, FALSE otherwise.


Method hasCardMany()

Tests if this field has a cardinality greater than one.

Usage
BiodbEntryField$hasCardMany()
Returns

TRUE if the cardinality of this field is many, FALSE otherwise.


Method forbidsDuplicates()

Tests if this field forbids duplicates.

Usage
BiodbEntryField$forbidsDuplicates()
Returns

TRUE if this field forbids duplicated values, FALSE otherwise.


Method isCaseInsensitive()

Tests if this field is case sensitive.

Usage
BiodbEntryField$isCaseInsensitive()
Returns

TRUE if this field is case insensitive, FALSE otherwise.


Method getClass()

Gets the class of this field's value.

Usage
BiodbEntryField$getClass()
Returns

class) of this field.


Method isObject()

Tests if this field's type is a class.

Usage
BiodbEntryField$isObject()
Returns

TRUE if field's type is a class, FALSE otherwise.


Method isDataFrame()

Tests if this field's type is data.frame.

Usage
BiodbEntryField$isDataFrame()
Returns

TRUE if field's type is data frame, FALSE otherwise."


Method isAtomic()

Tests if this field's type is an atomic type.

Usage
BiodbEntryField$isAtomic()
Returns

character, integer, double or logical), FALSE otherwise.


Method isVector()

Tests if this field's type is a basic vector type.

Usage
BiodbEntryField$isVector()
Returns

character, integer, double or logical), FALSE otherwise.


Method equals()

Compares this instance with another, and tests if they are equal.

Usage
BiodbEntryField$equals(other, fail = FALSE)
Arguments
other

Another BiodbEntryField instance.

fail

If set to TRUE, then throws error instead of returning FALSE.

Returns

TRUE if they are equal, FALSE otherwise.


Method updateWithValuesFrom()

Updates fields using values from other instance. The updated fields

Usage
BiodbEntryField$updateWithValuesFrom(other)
Arguments
other

Another BiodbEntryField instance.

are

'alias' and 'computable.from'. No values will be removed from those vectors. The new values will only be appended. This allows to extend an existing field inside a new connector definition.

Returns

Nothing.


Method print()

Print informations about this entry.

Usage
BiodbEntryField$print()
Returns

Nothing.


Method getCardinality()

Gets the field's cardinality.

Usage
BiodbEntryField$getCardinality()
Returns

The cardinality: "one" or "many".


Method check()

Checks if essential values are defined.

Usage
BiodbEntryField$check()
Returns

Nothing.


Method clone()

The objects of this class are cloneable with this method.

Usage
BiodbEntryField$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Parent class BiodbEntryFields.

Examples

# Get the class of the InChI field.
mybiodb <- biodb::newInst()
inchi.field.class <- mybiodb$getEntryFields()$get('inchi')$getClass()

# Test the cardinality of a field
card.one <- mybiodb$getEntryFields()$get('name')$hasCardOne()
card.many <- mybiodb$getEntryFields()$get('name')$hasCardMany()

# Get the description of a field
desc <- mybiodb$getEntryFields()$get('inchi')$getDescription()

# Terminate instance.
mybiodb$terminate()


pkrog/biodb documentation built on Nov. 29, 2022, 4:24 a.m.