Home Reference Source
import Collection from '@fnndsc/chrisapi'
public class | source

Collection

Collection+Json utility object.

Static Method Summary

Static Public Methods
public static

Create an empty Collection+Json object.

public static

getErrorMessage(collection: Object): string

Get the error message from the collection object.

public static

Get an item's data (descriptors).

public static

getLinkRelationUrls(obj: Object, relationName: string): string[]

Get the list of urls for a link relation from a collection or item object.

public static

getQueryParameters(queryArr: Object[]): string[]

Get the list of descriptor names within a Collection+Json query array.

public static

Get the list of descriptor names within a collection's template object.

public static

Get the total number of items from a collection object.

public static

getUrl(collection: Object): string

Get the url of the representation given by a collection obj.

public static

makeTemplate(descriptorsObj: Object): Object

Make a Collection+Json template object from a regular object whose properties are the item descriptors.

Static Public Methods

public static createCollectionObj(): Object source

Create an empty Collection+Json object.

Return:

Object

template object

public static getErrorMessage(collection: Object): string source

Get the error message from the collection object.

Params:

NameTypeAttributeDescription
collection Object

Collection+Json collection object

Return:

string

error message

public static getItemDescriptors(item: Object): Object source

Get an item's data (descriptors).

Params:

NameTypeAttributeDescription
item Object

Collection+Json item object

Return:

Object

object whose properties and values are the item's descriptor names and values respectively

public static getLinkRelationUrls(obj: Object, relationName: string): string[] source

Get the list of urls for a link relation from a collection or item object.

Params:

NameTypeAttributeDescription
obj Object

Collection+Json collection or item object

relationName string

name of the link relation

Return:

string[]

list of urls

public static getQueryParameters(queryArr: Object[]): string[] source

Get the list of descriptor names within a Collection+Json query array.

Params:

NameTypeAttributeDescription
queryArr Object[]

Collection+Json query array

Return:

string[]

list of query parameter names

public static getTemplateDescriptorNames(template: Object): string[] source

Get the list of descriptor names within a collection's template object.

Params:

NameTypeAttributeDescription
template Object

Collection+Json template object

Return:

string[]

list of descriptor names

public static getTotalNumberOfItems(collection: Object): number source

Get the total number of items from a collection object.

Params:

NameTypeAttributeDescription
collection Object

Collection+Json collection object

Return:

number

total number of items or -1 if the collection objects doesn't contain that information

public static getUrl(collection: Object): string source

Get the url of the representation given by a collection obj.

Params:

NameTypeAttributeDescription
collection Object

Collection+Json collection object

Return:

string

url of the resource representation

public static makeTemplate(descriptorsObj: Object): Object source

Make a Collection+Json template object from a regular object whose properties are the item descriptors.

Params:

NameTypeAttributeDescription
descriptorsObj Object

item descriptors object

Return:

Object

template object