Skip to main content

DAO Layer

The DAO (Data Access Object) layer in io-oidis-services provides an object-oriented engine for loading, composing, and querying hierarchical JSON-based configuration. Unlike traditional database DAOs, this layer focuses on configuration management — parsing JSONP resource files into typed class instances with support for inheritance, imports, and localization.

Package: io-oidis-services  |  Namespace: Io.Oidis.Services.DAO

Architecture​

                 ┌──────────────┐
│ BaseDAO │ ← Core: load, cache, compose
└──────┬───────┘
┌────────────┼───────────────┐
▼ ▼
┌─────────────┐ ┌──────────────────────┐
│ BasePageDAO │ │ InstallationRecipeDAO │
└─────────────┘ └──────────────────────┘
Page controllers Installation protocols
with localization with download/execute

Supporting Classes​

ClassRole
ResourcesExtends JsonpFileReader with Extend() and DeepClone() helpers for merging configurations

BaseDAO​

BaseDAO is the core class providing object-oriented data parsed from external JSONP resource files. It handles:

  • Configuration loading — Asynchronous JSONP file loading via Resources.Load()
  • Inheritance — extendsConfig property chains parent configurations
  • Imports — imports array references other configuration files as named variables
  • Localization — Language-specific configuration overlays (EN, CZ, CN)
  • Static caching — Loaded resources are cached to avoid repeated HTTP requests
  • Configuration library — Runtime utility functions (Echo, Log, Warning, Error) injected into configuration instances

Key Methods​

MethodDescription
Load($language, $asyncHandler, $force)Load the configuration for a given language, resolving inheritance chain and imports
getStaticConfiguration()Return the raw parsed configuration data
getConfigurationInstance()Return the configuration as a class instance with inheritance, imports, and library merged
ConfigurationLibrary($value?)Get or set the library object injected into configuration instances
getParentDAO()Return the parent DAO from extendsConfig resolution
getImportedDAO($variableName)Return an imported DAO by its variable name
setConfigurationPath($value)Set the JSONP file path used as data source
UnloadResource($filePath)Static method to remove a resource from the global cache

Configuration Hierarchy​

When BaseDAO.Load() is called, it:

  1. Loads the JSONP file at configurationPath
  2. Follows the extendsConfig chain, merging parent data with Resources.Extend()
  3. Resolves imports — each imported file is loaded into its own DAO instance
  4. Applies localization overlays for the requested language
  5. Caches the result in a static ArrayList keyed by file path and language

The getConfigurationInstance() method then composes all these layers into a single prototype-based object where $super references the parent configuration and import variables are accessible as named properties.

Localization Overlays​

A configuration file is treated as written in the DAO's default language — LanguageType.EN unless the subclass calls setDefaultLanguage() in its constructor. The overlay mechanics follow from that:

  • Load($language) with the default language returns the file as is; no overlay is loaded.
  • Load($language) with any other language looks up localization[<language lowercased>] in the base file (e.g. "cz" for LanguageType.CZ) and deep-merges that overlay over a clone of the base. Keys missing in the overlay keep the base value, so an incomplete translation falls back per key.
  • The language passed to Load() is not validated against LanguageType — only setDefaultLanguage() is.

A file whose texts are Czech therefore needs setDefaultLanguage(LanguageType.CZ) and localization: {en: "…"}; with the EN default, requesting LanguageType.EN would return the Czech base untouched.

imports and extendsConfig are loaded by DAO instances created through the static getDaoInterfaceClassName(), which returns plain BaseDAO by default. Those instances have the EN default, so a non-EN base language is lost for imported files unless the subclass overrides getDaoInterfaceClassName() to return itself.

On the backend use the Hub Resources handler (getResourcesHandler() override, see MailEngineDAO) so JSONP is read from the file system.

BasePageDAO​

Extends BaseDAO for page controller configurations. Adds page-specific accessors:

MethodDescription
getPageConfiguration()Return the typed IBasePageLocalization data
getCacheFilePath()Return the path used for page static cache loading
getPageTitle()Return the configured page title
getPageLoadingText()Return the loading indicator text
getPageLoadingProgressText()Return the loading progress text
getModelArgs()Return the BasePanelViewerArgs for the page viewer

InstallationRecipeDAO​

Extends BaseDAO for managing multi-step installation protocols. This is the most complex DAO, orchestrating package download, installation, validation, and repair sequences.

Installation Protocols​

Protocol TypeSteps
VALIDATEvalidate
INSTALL_STATUSinstallCondition
INSTALLinstallCondition → selectSource → getSource → install → validate
UNINSTALLinstallCondition → uninstall
REPAIRinstallCondition → selectSource → getSource → repair → validate

Key Methods​

MethodDescription
getChain()Return the ordered list of package names to process
getPackage($name)Resolve and return a fully prepared IInstallationPackage with default handlers for source selection, download, and installation
RunInstallationChain($protocolType)Execute the full installation chain for a given protocol type, firing progress events
Abort()Cancel the running chain, aborting active downloads
getEvents()Return the event interface for subscribing to OnStart, OnChange, OnComplete, and OnError

Event Flow​

OnStart → OnChange (per step/package) → OnComplete
→ OnError (on failure)

Progress events carry InstallationProgressCode values indicating the current phase: CHAIN_START, STEP_START, DOWNLOAD_START, DOWNLOAD_CHANGE, EXTRACT_START, CLONE, VALIDATED, SKIPPED, CHAIN_END.

Configuration Interfaces​

IBaseConfiguration​

The minimal interface expected by any JSONP configuration file:

PropertyTypeDescription
versionstring?Unique version identifier
extendsConfigstring?Path to parent configuration for inheritance
$interfacestring?DAO parser identifier (e.g. IBasePageConfiguration)
importsIImports[]?Array of imported configuration references
localizationILocalization?Language-specific overlay paths
noCacheboolean?Disable resource caching
$superIBaseConfigurationReference to parent configuration instance
Echo, Log, Warning, ErrorFunctionsRuntime utility functions from the configuration library

IBasePageLocalization​

Extends IBaseConfiguration for page controllers:

PropertyTypeDescription
cacheFilestring?Path to GUI static cache for fast loading
titlestring?Page title value
loadingstring?Loading indicator text
loadingProgressstring?Loading progress text

IBaseInstallationRecipe Hierarchy​

The installation recipe interface hierarchy defines the package structure:

  • IInstallationPackage — A single installable package with name, version, source, and handler methods (validate, install, uninstall, repair)
  • IInstallationPackageSource — Platform-specific source URLs (x86/x64) with optional download options
  • IInstallationHandler — Callback signature ($status: boolean, $message?: string) => void used by all protocol steps
  • IInstallationEnvironment — The full configuration instance with packages map, current block, utilities, and connectors
  • IInstallationRecipeNotifications — Localized notification message templates for installation progress

File Structure​

source/typescript/Io/Oidis/Services/
├── DAO/
│ ├── BaseDAO.ts # Core configuration engine
│ ├── BasePageDAO.ts # Page controller extension
│ ├── InstallationRecipeDAO.ts # Installation protocol manager
│ └── Resources.ts # JSONP loading + merge helpers
└── Interfaces/DAO/
├── IBaseConfiguration.ts # Core configuration interface
├── IBasePageLocalization.ts # Page localization interface
├── IBaseInstallationRecipe.ts # Installation package interfaces
└── IInstallationUtils.ts # System utility interface for installations

See also: Configuration Overview | JSONP System | HttpProcessor Services