# Module: chiefData

Contains all the functions to manage the loading and processing of data, such as XML files, CSV files or JSON files. Additional file type processing should be added in this module.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - controllers/chiefData.js, line 1

### Requires

- module:dataBroker
- module:themeBroker
- module:configurator
- module:loggers
- @haystacks/constants
- path

### Methods

#### (inner) clearData(dataName) → {boolean}

Wipes out the data using the unique specified data name, if any is found in the D-0data structure data storage data hive.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataName` | string | The unique name of the data that should be cleared.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 368

##### Returns:

True or False to indicate if the data was cleared successfully or not.

Type
  boolean

#### (inner) getAndProcessCsvData(pathAndFilename, contextName) → {object}

Loads the specified file, parses it and converts all the data to the appropriate format.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pathAndFilename` | string | The path and file name of the CSV file that should be loaded and parsed into JSON objects.
`contextName` | string | The name that should be used when adding the objects to the D data structure for data-sharing.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 67

##### Returns:

A parsed CSV JSON object where all the values have been converted from their string representation into actual values of appropriate type.

Type
  object

#### (inner) getAndProcessXmlData(pathAndFilename) → {object}

Loads the specified file, parses it and converts all values into their appropriate data types.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pathAndFilename` | string | The path and file name of the XML file that should be loaded and parsed into JSON objects.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 91

##### Returns:

A parsed XML JSON object where all the values have been converted from their string representation into actual values of appropriate type.

Type
  object

#### (inner) getData(dataName) → {object|string|boolean|number|array}

Gets data from the D-Data structure data storage data hive.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataName` | string | The unique name the data should be stored under.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 348

##### Returns:

The data element or object that was stored if any was found.

Type
  object | string | boolean | number | array

#### (inner) loadAllJsonData(dataPath, contextName)

Loads all of the JSON data at the specified path. Can be used to load account data, transaction history logs, activity logs, or any other kind of JSON data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataPath` | string | The path to the JSON files that should be loaded.
`contextName` | string | The type of data that should be loaded.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 298

##### Returns:

A JSON object that contains all of the data that was loaded and merged together.

#### (inner) searchForUniversalDebugConfigSetting(appConfigPathName, frameworkConfigPathName) → {boolean}

Searches all of the config data files for a general solution to the debugSettings configuration setting.

##### Parameters:

Name | Type | Description
--- | --- | ---
`appConfigPathName` | string | The name of the configuration setting that has the path for the appConfigPath.
`frameworkConfigPathName` | string | The name of the configuration setting that has the path for the frameworkConfigPath.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 30

##### Returns:

A True or False to indicate if the debugSettings was found to be true in either of the configuration settings (appConfig Or frameworkConfig).

Type
  boolean

#### (inner) setupAllCsvData(dataPathConfigurationName, contextName) → {object}

Sets up all of the specified CSV data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataPathConfigurationName` | string | The name of the configuration setting that has the path we should search.
`contextName` | string | The context name that should be used when adding data to the D data structure.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 114

##### Returns:

A JSON object that contains all of the data that was loaded from all the CSV files and merged together.

Type
  object

#### (inner) setupAllJsonConfigData(dataPathConfigurationName, contextName) → {object}

Sets up all of the JSON data at the specified configuration path.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataPathConfigurationName` | string | The name of the configuration setting that has the path we should search.
`contextName` | string | The context name that should be used when adding data to the D data structure.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 222

##### Returns:

A JSON object that contains all of the data that was loaded and merged together.

Type
  object

#### (inner) setupAllJsonConfigPluginData(configFilesPath, contextName)

Sets up all of the JSON data at the specified configuration path with regard to plugin configuration data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`configFilesPath` | string | The path to the configuration files that should be loaded.
`contextName` | string | The type of configuration data that should be loaded.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 265

##### Returns:

A JSON object that contains all of the data that was loaded and merged together.

#### (inner) setupAllXmlData(dataPathConfigurationName, contextName) → {object}

Sets up all of the specified XML data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataPathConfigurationName` | string | The name of the configuration setting that has the path we should search.
`contextName` | string | The context name that should be used when adding data to the D data structure.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 145

##### Returns:

A JSON object that contains all of the data that was loaded from all the XML files and merged together.

Type
  object

#### (inner) setupAllXmlPluginData(dataPathConfigurationName, contextName) → {object}

Sets up all of the specified XML data for the plugin.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataPathConfigurationName` | string | The fully qualified path to the data files that should be loaded and parsed or The name of the configuration setting that has the path we should search..
`contextName` | string | The context name that should describe the kind of data that is being loaded and parsed.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 177

##### Returns:

A JSON object that contains all of the data that was loaded from all the XML files and merged together.

Type
  object

#### (inner) storeData(dataName, data) → {boolean}

Persist some data to the data storage in the D-data structure.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dataName` | string | The name of the data, unique name used to store the data in the data structure.
`data` | object | string | boolean | number | array | The data that should be stored.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefData.js, line 325

##### Returns:

True or False to indicate if the data was stored successfully or not.

Type
  boolean