MetadataActionBase: Base class for metadata actions

MetadataActionBaseR Documentation

Base class for metadata actions

Description

Base class for metadata actions

Base class for metadata actions

Details

This class is the base for metadata actions. Any action will be executed by calling the method execute_read in the read direction, and execute_write in the write direction. Actions are parametrized with the settings field; the settings are set by merging the class-specific base_settings with the partial or full settings passed on construction (i.e. base settings are overridden by instance settings).

Instance settings are composed from base settings (which override the base settings and optional params "sub-settings". The action is executed once for every params sub-settings, which are applied on top of the instance base settings.

This sounds complicated, but is quite simple. Examples:

action: mapping
explicit: TRUE
params:
- {source: FIELD1, target: field1}
- {source: FIELD2, target: field2}

Here, FIELD1 is mapped to field1, FIELD2 is mapped to field2, and explicit = TRUE is valid for both entries. Specific entries may override instance settings:

action: mapping
explicit: TRUE
params:
- {source: FIELD1, target: field1}
- {source: FIELD2, target: field2, explicit: FALSE}
- {source: FIELD3, target: field3}

Here, explicit = TRUE is valid for the first and third entries.

If no params are given, a single action is executed using instance settings:

action: mapping
explicit: TRUE
source: field1
target: FIELD1

Note that explicit=TRUE overrides the base_settings value of explicit=FALSE. Not setting explicit at all would result in explicit=FALSE behaviour.

Implementing classes should

  • specify appropriate base_settings

  • implement process_read and process_write, which process a single action (i.e. one params entry). The action obtains the data input (an MsBackendMapping) and a params, which is the merged (sic!) version of parameters. I.e., it contains the base_settings overridden by the settings overridden by the params entry. Both return the modified data (i.e. an MsBackendMapping object) again.

Public fields

name

Action name

base_settings

Class base settings

settings

Instance settings

Methods

Public methods


Method log_level()

Log a message with specified level

Usage
MetadataActionBase$log_level(level, message)
Arguments
level

Log level, as specified in package ???

message

Message to log


Method new()

Constructor

Usage
MetadataActionBase$new(settings)
Arguments
settings

List of class-specific settings which override the base settings.


Method execute_read()

Execution wrapper: read

Usage
MetadataActionBase$execute_read(backend)
Arguments
backend

MsBackendMapping to execute the metadata mapping step on execute is the wrapper around process. If there are params, i.e. multiple steps are executed, execute loops through them. (The basic settings are updated with params, then the action is run.) If there are no params, only a single step is executed (with the "basic" settings.)


Method process_read()

Action implementation

Usage
MetadataActionBase$process_read(data, params)
Arguments
data

MsBackendMapping to execute the metadata mapping step on

params

List of parameters for a single action (one params entry fully merged.) process executes a transformation method and returns the transformed backend.

Here is where the implementation goes.


Method execute_write()

Execution wrapper: write

Usage
MetadataActionBase$execute_write(backend)
Arguments
backend

MsBackendMapping to execute the metadata mapping step on execute is the wrapper around process. If there are params, i.e. multiple steps are executed, execute loops through them. (The basic settings are updated with params, then the action is run.) If there are no params, only a single step is executed (with the "basic" settings.)


Method process_write()

Action implementation

Usage
MetadataActionBase$process_write(data, params)
Arguments
data

MsBackendMapping to execute the metadata mapping step on

params

List of parameters for a single action (one params entry fully merged.) process executes a transformation method and returns the transformed backend.

Here is where the implementation goes.


Method set_settings()

Set settings and verify that they are OK

Any action may/should check settings for consistency

Usage
MetadataActionBase$set_settings(settings)
Arguments
settings

List of settings, subclass-specific


Method merge_settings()

Update settings with step-specific entry

Usage
MetadataActionBase$merge_settings(param_settings)
Arguments
param_settings

A params entry from settings, i.e. a single action step.


Method clone()

The objects of this class are cloneable with this method.

Usage
MetadataActionBase$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


meowcat/SpectraMapping documentation built on May 14, 2024, 6:30 p.m.