X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=modules%2Fcommon-yangutils-resources%2Fsrc%2Fmain%2Fresources%2Fyangutils%2Fservices%2Fpath-utils.services.js;fp=modules%2Fcommon-yangutils-resources%2Fsrc%2Fmain%2Fresources%2Fyangutils%2Fservices%2Fpath-utils.services.js;h=4902ca9585f31305253120fc603b58d70137fbc9;hb=64bdac3d79d00b8541937565fea7f2283beee8a7;hp=90a11e40b52805a75c9267728f6a31c34b4131d6;hpb=32cd20aa178c0ab806f5dafb043a2dd7878da47a;p=dlux.git diff --git a/modules/common-yangutils-resources/src/main/resources/yangutils/services/path-utils.services.js b/modules/common-yangutils-resources/src/main/resources/yangutils/services/path-utils.services.js index 90a11e40..4902ca95 100644 --- a/modules/common-yangutils-resources/src/main/resources/yangutils/services/path-utils.services.js +++ b/modules/common-yangutils-resources/src/main/resources/yangutils/services/path-utils.services.js @@ -5,6 +5,7 @@ define([], function () { var service = { clearPath: clearPath, + checkEmptyIdentifiers: checkEmptyIdentifiers, createPathElement: createPathElement, getModuleNameFromPath: getModuleNameFromPath, getStorageAndNormalizedPath: getStorageAndNormalizedPath, @@ -53,7 +54,15 @@ define([], function () { } } - // TODO: add service's description + /** + * Translate path url into path elements array + * @param path + * @param prefixConverter + * @param importNodes + * @param getDefaultModuleCallback + * @param notIdentifiers + * @returns {Array} + */ function translate(path, prefixConverter, importNodes, getDefaultModuleCallback, notIdentifiers) { var pathStrElements = path.split('/').filter(function (e) { return e !== ''; @@ -125,6 +134,17 @@ define([], function () { }); } + /** + * Check if in path elements array is empty identifier + * @param pathArray + * @returns {*} + */ + function checkEmptyIdentifiers(pathArray){ + return pathArray.some(function (item) { + return item.hasEmptyIdentifier(); + }); + } + /** * Service for filling API url object from url string data * @param pathArrayIn @@ -209,7 +229,12 @@ define([], function () { return retObj; } - // TODO: add service's description + /** + * Fill path element's identifiers + * @param identifiers + * @param label + * @param value + */ function fillIdentifiers(identifiers, label, value) { identifiers.some(function (i) { var identifierMatch = i.label === label; @@ -327,6 +352,12 @@ define([], function () { }); }; + this.hasEmptyIdentifier = function () { + return this.identifiers.some(function (item) { + return item.value.length === 0; + }); + }; + this.toString = function () { return (this.module ? this.module + ':' : '') + this.name + '/' + (this.hasIdentifier() ? this.getIdentifierValues().join('/') + '/' : '');