saveResultsFilteredForExport
Retrieves a JSON object from the application state and stores it for later export.
saveResultsFilteredForExport()
Purpose
Retrieves a JSON object from the application state and stores it for later export.
The function is typically used to collect processed or filtered measurement results that should be included in reports, CSV files, or other export formats. The target data is selected dynamically through the pipeline configuration, allowing different result objects to be exported without modifying the implementation.
The actual storage mechanism is handled by the export system and may use IndexedDB or file-based storage depending on the current environment.
Location
src/app/services/fileManager/file-manager.service.ts
Signature
saveResultsFilteredForExport(
pipelineConfig: PipelineStageConfig
): OperatorFunction<StatusObject, Observable<any>>
Parameters
| Parameter | Type | Description |
|---|---|---|
pipelineConfig |
PipelineStageConfig |
Current pipeline stage configuration containing the state location of the object to export. |
Returns
OperatorFunction<StatusObject, Observable<any>>
RxJS operator which retrieves a JSON object from the application state and adds it to the export data.
Configuration
Required Parameters
| Parameter | Description |
|---|---|
resKey |
State key containing the object to export |
resGroup |
State group containing the object to export |
Example Configuration
{
"resKey": "filteredResults",
"resGroup": "temp"
}
Workflow
Read resKey and resGroup
↓
Locate object in state
↓
Save object for export
↓
Execute onSuccess
State Dependencies
Reads
state[resGroup][resKey]
Example:
state.temp.filteredResults
Export Handling
The selected object is passed to:
await this.handleSaveResult(jsonToSave);
handleSaveResult()
Saves a JSON result object for future export.
Depending on the capabilities of the current platform and environment, the result is stored using one of the following mechanisms:
| Storage Method | Description |
|---|---|
| IndexedDB | Used in web environments to persist export data locally within the browser. |
| CSV File | Used in environments that support direct file access to create or append export data in CSV format. |
Parameters
| Parameter | Type | Description |
|---|---|---|
jsonToSave |
Record<string, unknown> |
The result object that should be stored for later export. |
Example
{
measurementId: "12345",
aox: 543.2,
timestamp: "2026-06-09T10:30:00Z"
}
The object is stored by the export system and can later be included in reports, CSV exports, or other export formats.
Example Input
state.temp.filteredResults = {
measurementId: "12345",
aox: 543.2,
status: "valid"
};
Saved Object
{
"measurementId": "12345",
"aox": 543.2,
"status": "valid"
}
Success Behaviour
On successful execution:
- The configured object is retrieved from the application state.
- The object is passed to the export handling system.
- The configured
onSuccessevent target is executed.
pipelineConfig.executeStage(
pipelineConfig.stageConfig.eventTargets?.onSuccess,
'onSuccess',
pipelineConfig.stage
);
Failure Behaviour
The stage fails when:
resKeyis not configured.resGroupis not configured.
In this case:
pipelineConfig.executeStage(
pipelineConfig.stageConfig.eventTargets?.onFail,
'onFail',
pipelineConfig.stage
);
is executed.
Typical Use Cases
- Saving filtered measurement results for export
- Preparing report data
- Collecting exportable result objects
- Building export datasets from pipeline state
- Storing processed measurement information for later file generation
Notes
- The function does not modify the selected object.
- The object is retrieved dynamically from the application state.
- Export processing is delegated to
handleSaveResult(). - The exported data can originate from any state group and key defined in the configuration.
- Missing configuration immediately triggers the configured
onFailevent. - The storage mechanism depends on the capabilities of the current platform and may use IndexedDB or file-based storage.