Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractDAO<K, T>

An abstract data access layer API, meant to (somewhat) mirror the DAO interfaces inside OpenNMS. Used to retrieve model data like alarms, events, etc. from the OpenNMS ReST API in a consistent way.

Type parameters

  • K

    the ID/key type (number, string, etc.)

  • T

    the model type (OnmsAlarm, OnmsEvent, etc.)

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private propertiesCache

propertiesCache: any

A local cache of v2 DAO properties (api/v2/DAO/properties)

Accessors

http

server

Methods

Abstract find

  • find(filter?: Filter): Promise<T[]>
  • Find all model objects given an optional filter.

    Parameters

    • Optional filter: Filter

      the filter to use when retrieving a list of model objects

    Returns Promise<T[]>

findValues

  • findValues(propertyId: string, options?: any): Promise<any>
  • Finds the values for the given propertyId, if it exists.

    Parameters

    • propertyId: string

      The propertyId to find the values for

    • Optional options: any

      Some additional options. May be implementer dependent, such as limit, or value restrictions

    Returns Promise<any>

    A promise containing the values.

Abstract get

  • get(id: K): Promise<T>
  • Retrieve a model object.

    Parameters

    • id: K

      the ID of the object

    Returns Promise<T>

Protected getApiVersion

  • getApiVersion(): number
  • Retrieve the API version from the currently configured server.

    Returns number

Protected getCount

  • getCount(data: any): number
  • A convenience method to make it easy for implementers to extract the count (or totalCount) values from response data.

    Parameters

    • data: any

    Returns number

getFilterProcessor

Protected getOptions

getPropertiesCache

  • getPropertiesCache(): Promise<any>
  • Returns or creates a cache of properties for this dao.

    Returns Promise<any>

    the cache for this dao. It is created if it does not exist.

Protected onSetServer

Protected parseResultList

  • parseResultList(result: any, dataFieldName: string, path: string, mapCallbackFunction: any): any[]
  • Fetches the data from the result and verfifes that the dataFieldName exists in the data property. If it does not exist, an exception is thrown.

    Parameters

    • result: any

      The result to fetch the data from

    • dataFieldName: string

      The property name (basically result.data[dataFieldName].

    • path: string

      The path where the result was fetched from. This is for error handling

    • mapCallbackFunction: any

      Callback function to convert each entry from result.data[dataFieldName].

    Returns any[]

searchProperties

searchProperty

  • Gets the property identified by the id if it exists.

    Parameters

    • id: string

      The id to search the property by.

    Returns Promise<SearchProperty | undefined>

Protected Abstract searchPropertyPath

  • searchPropertyPath(): string

Protected toDate

  • toDate(from: any): Moment | undefined
  • Convert the given value to a date, or undefined if it cannot be converted.

    Parameters

    • from: any

    Returns Moment | undefined

Protected toNumber

  • toNumber(from: any): number | undefined
  • Convert the given value to a number, or undefined if it cannot be converted.

    Parameters

    • from: any

    Returns number | undefined

Protected useJson

  • useJson(): boolean

Protected visitClause

Protected visitFilter

  • Iterate over a Filter object and its children.

    Parameters

    • filter: Filter

      the filter to visit

    • visitor: IFilterVisitor

      the class to invoke while visiting the filter

    Returns void

Generated using TypeDoc