GRIS_MAPPING
in package
Class to manage mappingss
With this class mappingss can be managed
PHP version 8
Copyright (c) 2024, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany
Tags
Table of Contents
- dbtable = 'gris_mapping'
- The constant for the database table
- settings_group = "mapping"
- The constant for the settings group
- $classname : object
- The name of the class
- $dbconnection : object
- The database object for managing the connection
- $i18n : object
- The object for translations
- $mapping : object
- The object for institutes
- $settings : object
- The object for settings
- $state : object
- The object for logs
- __construct() : mixed
- The class constructor
- delete_args() : bool
- Delete arguments from a mapping entry
- delete_mapping() : bool
- Delete a mapping entry
- delete_source_var() : bool
- Delete a source variable from a mapping entry
- get_array_structure_json() : array<string|int, mixed>
- Returns the structure of the array for jstree (values as title attribute)
- get_attribute_mapping() : array<string|int, mixed>
- Get the mapping for a single attribute and a given import ID
- get_mapping_list() : array<string|int, mixed>
- Get the mapping for a given import ID
- get_object_attributes() : array<string|int, mixed>
- Get all attributes of an object
- get_resourcetype_mapping() : array<string|int, mixed>
- Get the corresponding GRIS resourcetype for a foreign resourcetype
- get_resourcetype_mappings_for_source() : array<string|int, mixed>
- Get resourcetype mappings for a source
- get_restype_mapping_sources() : array<string|int, mixed>
- Get all sources from the resourcetype mappings
- map_gris_attributes() : array<string|int, mixed>
- Mapping of gris attributes
- save_value() : bool
- Saves an entry in the mapping table
- set_resourcetype_mapping() : string
- Sets a resourcetype mapping
- eval_source_var() : Return
- Evaluate the source variable
Constants
dbtable
The constant for the database table
public
mixed
dbtable
= 'gris_mapping'
settings_group
The constant for the settings group
public
mixed
settings_group
= "mapping"
Properties
$classname
The name of the class
private
object
$classname
= NULL
Tags
$dbconnection
The database object for managing the connection
private
object
$dbconnection
= NULL
Tags
$i18n
The object for translations
private
object
$i18n
Tags
$mapping
The object for institutes
private
object
$mapping
= array()
Tags
$settings
The object for settings
private
object
$settings
= null
Tags
$state
The object for logs
private
object
$state
Tags
Methods
__construct()
The class constructor
public
__construct() : mixed
Initializes the objects
Return values
mixed —delete_args()
Delete arguments from a mapping entry
public
delete_args(string $gris_var, int $import_id) : bool
Parameters
- $gris_var : string
- $import_id : int
Return values
bool —Returns true for success and false for error
delete_mapping()
Delete a mapping entry
public
delete_mapping(string $gris_var, int $import_id) : bool
Parameters
- $gris_var : string
- $import_id : int
Return values
bool —Returns true for success and false for error
delete_source_var()
Delete a source variable from a mapping entry
public
delete_source_var(string $gris_var, int $import_id) : bool
Parameters
- $gris_var : string
- $import_id : int
Return values
bool —Returns true for success and false for error
get_array_structure_json()
Returns the structure of the array for jstree (values as title attribute)
public
get_array_structure_json(array<string|int, mixed> $import_array[, string $structure = NULL ][, array<string|int, mixed> $filter = NULL ][, array<string|int, mixed> $selected_ids = NULL ]) : array<string|int, mixed>
Parameters
- $import_array : array<string|int, mixed>
-
The import array
- $structure : string = NULL
-
The structure of the parent nodes
- $filter : array<string|int, mixed> = NULL
-
An array with attribute names to filter
- $selected_ids : array<string|int, mixed> = NULL
-
An array with IDs to be marked as selected (if not filtered before)
Return values
array<string|int, mixed> —Returns the structure as an array
get_attribute_mapping()
Get the mapping for a single attribute and a given import ID
public
get_attribute_mapping(int $import_id, string $attribute) : array<string|int, mixed>
Parameters
- $import_id : int
-
The import ID
- $attribute : string
-
The name of the attribute
Return values
array<string|int, mixed> —Returns the mapping for attribute and mapping ID
get_mapping_list()
Get the mapping for a given import ID
public
get_mapping_list(int $import_id) : array<string|int, mixed>
Parameters
- $import_id : int
-
The import ID
Return values
array<string|int, mixed> —Returns the mapping list
get_object_attributes()
Get all attributes of an object
public
get_object_attributes(string $object) : array<string|int, mixed>
Parameters
- $object : string
-
The name of the object (gris_resource, gris_project, gris_history)
Return values
array<string|int, mixed> —Returns a list of GRIS attributes (2 dimensional)
get_resourcetype_mapping()
Get the corresponding GRIS resourcetype for a foreign resourcetype
public
get_resourcetype_mapping(string $foreign_resourcetype, string $source) : array<string|int, mixed>
Parameters
- $foreign_resourcetype : string
-
The foreign resourcetype
- $source : string
-
The name of source
Return values
array<string|int, mixed> —Returns the ID of the GRIS resourcetype or NULL if not found
get_resourcetype_mappings_for_source()
Get resourcetype mappings for a source
public
get_resourcetype_mappings_for_source(string $source) : array<string|int, mixed>
Parameters
- $source : string
-
The name of source
Return values
array<string|int, mixed> —Returns the ID of the GRIS resourcetype or NULL if not found
get_restype_mapping_sources()
Get all sources from the resourcetype mappings
public
get_restype_mapping_sources() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns the list of sources
map_gris_attributes()
Mapping of gris attributes
public
map_gris_attributes(int $import_id, array<string|int, mixed> $import_raw_data) : array<string|int, mixed>
Input variables:
$item = array( gris_mapping_source_var, gris_mapping_type = 2 (function, s.o.), gris_mapping_function = 1 (oax_map_resourcetypes), gris_mapping_args );
Parameters
- $import_id : int
-
The import ID
- $import_raw_data : array<string|int, mixed>
-
The raw import data
Return values
array<string|int, mixed> —Returns the mapped data
save_value()
Saves an entry in the mapping table
public
save_value(array<string|int, mixed> $data) : bool
Example:
$data = array( "gris_mapping_gris_var" => NULL, "gris_mapping_source_var" => NULL, "gris_import_id" => NULL, "gris_mapping_type" => NULL, "gris_mapping_function" => NULL, "gris_mapping_args" => NULL );
Parameters
- $data : array<string|int, mixed>
-
The data of the mapping entry
Return values
bool —Returns true for success and false for errror
set_resourcetype_mapping()
Sets a resourcetype mapping
public
set_resourcetype_mapping(string $name, string $source, int $resourcetype_id) : string
Parameters
- $name : string
-
The name of source resourcetype
- $source : string
-
The name of the source
- $resourcetype_id : int
-
The ID of the resourcetype in GRIS
Return values
string —The name of the resourcetype
eval_source_var()
Evaluate the source variable
private
eval_source_var(mixed $import_raw_data, mixed $source_var) : Return
Parameters
- $import_raw_data : mixed
- $source_var : mixed
Return values
Return —the value of the source var or NULL if it does not exist