Factories#

ItemFactory#

class ItemFactory()#

A factory class for item collections

static ItemFactory.ItemFactoryOptions()#
Arguments:
  • url (string) – Custom URL for collection

  • customParameters (object) – Custom parameters object

static ItemFactory.create(search, project, options)#

Creates the item collection

Arguments:
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • options (ItemFactoryOptions) – Additional options

Returns:

Collection – - The items collection

Examples:

var factory = Factories.Collections.Items;
var collection = factory.create(this.options.search, this.options.project, options);
static ItemFactory.createFromParams(params, url)#

Creates the item collection from a parameters object

Arguments:
  • params (Object) – The parameters object

  • url (String) – Custom url, if required

Returns:

Collection – - The items collection

Examples:

var factory = Factories.Collections.Items;
var collection = factory.createFromParams(this.getCollectionParams());

AggregationsFactory#

class AggregationsFactory()#

A factory class for item collections

static AggregationsFactory.AggregationsFactoryOptions()#
Arguments:
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • content (String) – If fetch is not overriden, specifies the outer aggregation field

  • limit (String) – If fetch is not overriden, specifies size of the aggregation

  • field (String) – If fetch is not overriden, specifies the inner aggregation field

  • aggregate_method (String) – If fetch is not overriden, specifies aggregation method

static AggregationsFactory.create(type, options)#

Creates the aggregations collection

Arguments:
  • type (string) – Collection type, used for caching so make it unique per widget

  • extensions (AggregationsFactoryOptions) – Functions and properties in this object will be attached to the created collection prototype

Returns:

Collection – - The aggregations collection

Examples:

var factory = Factories.Collections.Aggregations;
var collection = factory.create('MyCollection', this.getCollectionParams());
static AggregationsFactory.createCommunities(type, project, search, limit, communityTypes, options)#

Creates the community aggregations collection

Arguments:
  • type (string) – Collection type, used for caching so make it unique per widget

  • extensions (AggregationsFactoryOptions) – Functions and properties in this object will be attached to the created collection prototype

Returns:

Collection – - The aggregations collection

Examples:

var factory = Factories.Collections.Aggregations;
var collection = factory.createCommunities('MyCollection', this.getCollectionParams());
static AggregationsFactory.createFacets(type, project, search, limit, fields, options)#

Creates the facets aggregations collection

Arguments:
  • type (string) – Collection type, used for caching so make it unique per widget

  • extensions (AggregationsFactoryOptions) – Functions and properties in this object will be attached to the created collection prototype

Returns:

Collection – - The aggregations collection

Examples:

var factory = Factories.Collections.Aggregations;
var collection = factory.createFacets('MyCollection', this.getCollectionParams());

FacetsFactory#

class FacetsFactory()#

A factory class for item collections

static FacetsFactory.FacetsFactoryOptions()#
Arguments:
  • itemsCollection (Collection) – If passed, links the collection to the item collection updates

  • nof_facets (Number) – Limits the number of facet values per facet

  • facet_fields (Array.<string>) – Only fetch specific facet fields

  • url (string) – Custom URL passed from custom widgets

  • customParameters (object) – Custom parameters object

static FacetsFactory.create(search, project, options)#

Creates the facets collection

Arguments:
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • options (FacetsFactoryOptions) – Options

Returns:

Collection – - The items collection

Examples:

var factory = Factories.Collections.Facets;
var collection = factory.create(this.options.search, this.options.project);

MockItemFactory#

class MockItemFactory()#

A factory class for mocked item collections

static MockItemFactory.create(search, project, items=null)#

Creates the mocked item collection, with preloaded data and detached from the backend

Arguments:
  • search (Model) – The search model (this.options.search)

  • project (Model) – The project (this.options.project)

  • items (Array.<object>) – Items to preload the collection with

Returns:

Collection – - The items collection

Examples:

var factory = Factories.Collections.MockItems;
var collection = factory.create(this.options.search, this.options.project, [{ title: 'Item title' }]);