var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// <reference path="../../base/BaseClass.ts"/> var econda; (function (econda) { var recengine; (function (recengine) { var context; (function (context) { /** * Represents a category, we want to get recommendations for. * A category must have a type, which is in general, the field name. E.g. "productcategory", "brand", .. * The category itself can be identified by id (as given in import feed) or path. * * A context category is always assigned to a {@link econda.recengine.context.Context} object. Normally the easiest way * is to use a category configuration in {@link econda.recengine.context.Context#setCategories} * * // example: pass single category as configuration and identify category by path as string * myContextObject.setCategories({ * type: 'brand', * path: { * path: 'my>category>path', * delimiter: '>' * } * }); * * // example: pass single category as configuration and identify category by path as an array * myContextObject.setCategories({ * type: 'brand', * path: ['my', 'category', 'path'] * }); * * // example: pass single category as category object and identify category by id * myContextObject.setCategories(new econda.recengine.context.CategoryReference({ * type: 'productcategory', * id: 'A142' * })); * * // example: pass different categories and types as array * widget.context.setCategories([ * { * type: 'productcategory', * path: { * path: 'home>Herren>Schuhe>Boots & Stiefel', * delimiter: '>' * } * },{ * type: 'productcategory', * path: { * path: 'home>Damen>Schuhe>Ballerinas', * delimiter: '>' * } * }, { * type: 'brand', * path: { * path: 'venice', * delimiter: '>' * } * } * ]); * * * Preferred way to identify a category is by its id. * * @class econda.recengine.context.CategoryReference */ var CategoryReference = (function (_super) { __extends(CategoryReference, _super); function CategoryReference(cfg) { if (cfg === void 0) { cfg = null; } _super.call(this); /** * Category type, this is the field name of category, e.g. "productcategory", "brand". See #setType for details. * @cfg {String} type * @accessor */ this.type = "productcategory"; /** * Category id, see #setCategory for details. * @cfg {String} id */ this.id = null; /** * Variant key, see #setVariant for details. * @cfg {String} variant */ this.variant = null; /** * Category path, see #setPath for details. * @cfg {Array|Object|String} path */ this.path = null; this.initConfig(cfg); } CategoryReference.prototype.getType = function () { return this.type; }; CategoryReference.prototype.setType = function (type) { this.type = type; return this; }; CategoryReference.prototype.getId = function () { return this.id; }; CategoryReference.prototype.setId = function (id) { this.id = id; return this; }; CategoryReference.prototype.getVariant = function () { return this.variant; }; CategoryReference.prototype.setVariant = function (key) { this.variant = key; return this; }; CategoryReference.prototype.getPath = function () { return this.path; }; /** * Set path, multiple formats allowed: * * Array of parts: * * cat.setPath(["part1", "part2"] // e.g. "tv", "lcd" * * Path as string: * * cat.setPath({ * path: "part1/part2", * delimiter: "/" * }); * * Path as string with default delimiter: * * cat.setPath("part1/part2"); * * If a single path element contains a delimiter, use array syntax or specify delimiter (see above). * * cat.setPath(["a/b"]); * * @param path * return (econda.recengine.context.CategoryReference) */ CategoryReference.prototype.setPath = function (path) { if (typeof (path) == 'string') { path = { "path": path, "delimiter": "/" }; } if (typeof (path) == 'object' && typeof (path.path) != 'undefined') { if (typeof (path.delimiter) == 'undefined') { path.delimiter = '/'; } path = path.path.split(path.delimiter); } this.path = path; return this; }; return CategoryReference; }(econda.base.BaseClass)); context.CategoryReference = CategoryReference; // end of class })(context = recengine.context || (recengine.context = {})); })(recengine = econda.recengine || (econda.recengine = {})); })(econda || (econda = {})); // end of module