Skip to content

web-backend


Class: FaultTreesService ​

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:15

Service for Fault Tree nested model operations. Provides collection and single-item retrieval, updates and label helpers.

Constructors ​

Constructor ​

new FaultTreesService(FaultTreeModel, nestedModelService, nestedModelHelperService): FaultTreesService

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:22

Construct the service with persistence and helper dependencies.

Parameters ​

FaultTreeModel ​

Model<FaultTreeDocument>

Mongoose model for FaultTree collection

nestedModelService ​

NestedModelService

Service to allocate IDs and shared nested model ops

nestedModelHelperService ​

NestedModelHelperService

Helper to link/unlink nested models to typed models

Returns ​

FaultTreesService

Methods ​

createFaultTree() ​

createFaultTree(body, typedModel): Promise<NestedModel>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:72

creates the type of nested model defined in the function name

Parameters ​

body ​

Partial<NestedModel>

a nested model, that needs to contain its parent id (easier to grab on frontend with getCurrentModel) and a label object with a name string and optional description string

typedModel ​

TypedModelType

is the typed model to be updated

Returns ​

Promise<NestedModel>

a promise with a nested model in it, which contains the basic data all the nested models have


deleteFaultTree() ​

deleteFaultTree(modelId, typedModel): Promise<void>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:104

finds and deletes the nested model in this collection with the give model id

Parameters ​

modelId ​

string

the id of the model we want to delete

typedModel ​

TypedModelType

is the typed model that this nested model belongs to

Returns ​

Promise<void>

a promise with the deleted model


getFaultTree() ​

getFaultTree(parentId): Promise<FaultTree[]>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:34

gets the collection of the nested model as defined by the function name (bayesian estimations, etc.)

Parameters ​

parentId ​

number

id of the parent model the nested model is number

Returns ​

Promise<FaultTree[]>

a promise with an array of the nested model of the type in the function name


getFaultTreeString() ​

getFaultTreeString(parentId): Promise<FaultTree[]>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:43

Retrieves Fault Trees by parent id (string form).

Parameters ​

parentId ​

string

Parent identifier as a string (ObjectId)

Returns ​

Promise<FaultTree[]>

Array of Fault Tree documents for the given parent


getSingleFaultTree() ​

getSingleFaultTree(modelId): Promise<FaultTree>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:52

gets a single model from the collection based on the id

Parameters ​

modelId ​

number

the id of the model to be retrieved

Returns ​

Promise<FaultTree>

the model which has the associated id


getSingleFaultTreeString() ​

getSingleFaultTreeString(modelId): Promise<FaultTree>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:61

Retrieves a single Fault Tree by string id.

Parameters ​

modelId ​

string

Document _id as a string (ObjectId)

Returns ​

Promise<FaultTree>

The matching Fault Tree document


updateFaultTreeLabel() ​

updateFaultTreeLabel(id, body): Promise<NestedModel>

Defined in: packages/web-backend/src/nestedModels/NestedModelsHelpers/fault-trees.service.ts:94

updates the label in the nested model

Parameters ​

id ​

string

the id of the nested model to be updated

body ​

Label

a label with a name and description

Returns ​

Promise<NestedModel>

a promise with the updated model with an updated label