opengate-js 11.18.2 → 11.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bower.json +1 -1
- package/dist/{opengate-api-bower-11.18.2.js → opengate-api-bower-11.18.3.js} +15 -7
- package/dist/opengate-api-bower-11.18.3.js.map +1 -0
- package/dist/{opengate-api-bower-11.18.2.min.js → opengate-api-bower-11.18.3.min.js} +4 -4
- package/dist/{opengate-api-bower-11.18.2.min.js.map → opengate-api-bower-11.18.3.min.js.map} +1 -1
- package/dist/src/provision/entities/SimpleBuilder.js +10 -2
- package/dist/src/provision/entities/SimpleBuilder.js.map +1 -1
- package/docs/ast/source/provision/entities/SimpleBuilder.js.json +9642 -8965
- package/docs/class/src/provision/entities/SimpleBuilder.js~SimpleBuilder.html +11 -11
- package/docs/coverage.json +2 -2
- package/docs/dump.json +22 -22
- package/docs/file/src/provision/entities/SimpleBuilder.js.html +7 -2
- package/docs/package.json +1 -1
- package/docs/source.html +211 -211
- package/package.json +1 -1
- package/src/provision/entities/SimpleBuilder.js +7 -2
- package/dist/opengate-api-bower-11.18.2.js.map +0 -1
|
@@ -265,13 +265,13 @@
|
|
|
265
265
|
</nav>
|
|
266
266
|
|
|
267
267
|
<div class="content" data-ice="content"><div class="header-notice">
|
|
268
|
-
<div data-ice="importPath" class="import-path"><pre class="prettyprint"><code data-ice="importPathCode">import SimpleBuilder from '<span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
268
|
+
<div data-ice="importPath" class="import-path"><pre class="prettyprint"><code data-ice="importPathCode">import SimpleBuilder from '<span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber15">opengate-js/src/provision/entities/SimpleBuilder.js</a></span>'</code></pre></div>
|
|
269
269
|
<span data-ice="access">public</span>
|
|
270
270
|
<span data-ice="kind">class</span>
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
|
|
274
|
-
<span data-ice="source">| <span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
274
|
+
<span data-ice="source">| <span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber15">source</a></span></span>
|
|
275
275
|
</div>
|
|
276
276
|
|
|
277
277
|
<div class="self-detail detail">
|
|
@@ -683,7 +683,7 @@ This function updates a entity of provision</p>
|
|
|
683
683
|
<span class="right-info">
|
|
684
684
|
|
|
685
685
|
|
|
686
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
686
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber24">source</a></span></span>
|
|
687
687
|
</span>
|
|
688
688
|
</h3>
|
|
689
689
|
|
|
@@ -778,7 +778,7 @@ This function updates a entity of provision</p>
|
|
|
778
778
|
<span class="right-info">
|
|
779
779
|
|
|
780
780
|
|
|
781
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
781
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber173">source</a></span></span>
|
|
782
782
|
</span>
|
|
783
783
|
</h3>
|
|
784
784
|
|
|
@@ -859,7 +859,7 @@ This function deletes a entity of provision</p>
|
|
|
859
859
|
<span class="right-info">
|
|
860
860
|
|
|
861
861
|
|
|
862
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
862
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber118">source</a></span></span>
|
|
863
863
|
</span>
|
|
864
864
|
</h3>
|
|
865
865
|
|
|
@@ -915,7 +915,7 @@ This function deletes a entity of provision</p>
|
|
|
915
915
|
<span class="right-info">
|
|
916
916
|
|
|
917
917
|
|
|
918
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
918
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber80">source</a></span></span>
|
|
919
919
|
</span>
|
|
920
920
|
</h3>
|
|
921
921
|
|
|
@@ -971,7 +971,7 @@ This function deletes a entity of provision</p>
|
|
|
971
971
|
<span class="right-info">
|
|
972
972
|
|
|
973
973
|
|
|
974
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
974
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber122">source</a></span></span>
|
|
975
975
|
</span>
|
|
976
976
|
</h3>
|
|
977
977
|
|
|
@@ -1030,7 +1030,7 @@ This function deletes a entity of provision</p>
|
|
|
1030
1030
|
<span class="right-info">
|
|
1031
1031
|
|
|
1032
1032
|
|
|
1033
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
1033
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber158">source</a></span></span>
|
|
1034
1034
|
</span>
|
|
1035
1035
|
</h3>
|
|
1036
1036
|
|
|
@@ -1089,7 +1089,7 @@ This function deletes a entity of provision</p>
|
|
|
1089
1089
|
<span class="right-info">
|
|
1090
1090
|
|
|
1091
1091
|
|
|
1092
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
1092
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber243">source</a></span></span>
|
|
1093
1093
|
</span>
|
|
1094
1094
|
</h3>
|
|
1095
1095
|
|
|
@@ -1177,7 +1177,7 @@ This function patch a entity of provision</p>
|
|
|
1177
1177
|
<span class="right-info">
|
|
1178
1178
|
|
|
1179
1179
|
|
|
1180
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
1180
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber207">source</a></span></span>
|
|
1181
1181
|
</span>
|
|
1182
1182
|
</h3>
|
|
1183
1183
|
|
|
@@ -1265,7 +1265,7 @@ This function updates a entity of provision</p>
|
|
|
1265
1265
|
<span class="right-info">
|
|
1266
1266
|
|
|
1267
1267
|
|
|
1268
|
-
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#
|
|
1268
|
+
<span data-ice="source"><span><a href="file/src/provision/entities/SimpleBuilder.js.html#lineNumber90">source</a></span></span>
|
|
1269
1269
|
</span>
|
|
1270
1270
|
</h3>
|
|
1271
1271
|
|
package/docs/coverage.json
CHANGED
package/docs/dump.json
CHANGED
|
@@ -40484,7 +40484,7 @@
|
|
|
40484
40484
|
"__docId__": 1519,
|
|
40485
40485
|
"kind": "file",
|
|
40486
40486
|
"name": "src/provision/entities/SimpleBuilder.js",
|
|
40487
|
-
"content": "'use strict';\r\n\r\nimport HttpStatus from 'http-status-codes';\r\nimport BaseProvision from '../BaseProvision';\r\nimport q from 'q';\r\n\r\nconst ERROR_VALUE_NOT_ALLOWED = 'value is not allowed. The value should be formatted as follows: ';\r\nconst ERROR_DATASTREAM_NOT_ALLOWED = 'Datastream is not allowed';\r\nconst schema_base = '/og_basic_types.json';\r\n\r\n/**\r\n * This class allow set simple values.\r\n */\r\nexport default class SimpleBuilder extends BaseProvision {\r\n\r\n /**\r\n * @param {!InternalOpenGateAPI} ogapi - this is ogapi instance\r\n * @param {!string} resource - this is the resource url where can be create/delete/update/read the entity\r\n * @param {!array} [allowedDatastreams] - Allowed datastreams to add into the new entity\r\n * @param {!array} [definedSchemas] - Jsonschema about all OpenGate specific types\r\n * @param {!Validator} [jsonSchemaValidator] - Json schema validator tool\r\n */\r\n constructor(ogapi, resource, allowedDatastreams, definedSchemas, jsonSchemaValidator, timeout) {\r\n super(ogapi, \"/organizations/\" + resource, timeout);\r\n if (typeof this._getEntityKey !== \"function\") {\r\n throw new Error(\"Must override method: _getEntityKey\");\r\n }\r\n this._setUrlParameters({\r\n flattened: true\r\n });\r\n this._entity = {};\r\n this._allowedDatastreams = allowedDatastreams;\r\n this._definedSchemas = definedSchemas;\r\n this._jsonSchemaValidator = jsonSchemaValidator;\r\n }\r\n\r\n _buildURL() {\r\n return this._resource + \"/\" + this.getEntityKey();\r\n }\r\n\r\n _validate() {\r\n let _this = this;\r\n let errors = [];\r\n Object.keys(this._entity).forEach(function(_id) {\r\n if (_id != 'resourceType') {\r\n if (!_this._definedSchemas[_id]) {\r\n throw new Error(ERROR_DATASTREAM_NOT_ALLOWED + ': ' + _id);\r\n }\r\n let jSchema = _this._definedSchemas[_id].value;\r\n if (_this._entity[_id].constructor === Array) {\r\n _this._entity[_id].forEach(function(item) {\r\n let value = item._value._current.value;\r\n if (!_this._jsonSchemaValidator.validate(schema_base, value)) {\r\n errors.push(_id + ' [' + value + '] ' + ERROR_VALUE_NOT_ALLOWED + JSON.stringify(jSchema));\r\n }\r\n });\r\n } else {\r\n let value = _this._entity[_id]._value._current.value;\r\n if (!_this._jsonSchemaValidator.validate(schema_base, value)) {\r\n errors.push(_id + ' [' + value + '] ' + ERROR_VALUE_NOT_ALLOWED + JSON.stringify(jSchema));\r\n }\r\n }\r\n }\r\n });\r\n\r\n if (errors.length > 0) {\r\n throw new Error(JSON.stringify(errors).replace(new RegExp(\"\\\"\", 'g'), \"\"));\r\n }\r\n }\r\n\r\n _composeElement() {\r\n this._validate();\r\n return this._entity;\r\n }\r\n\r\n /**\r\n * @return {string} - Entity identifier\r\n */\r\n getEntityKey() {\r\n return (this._getEntityKey() !== null) ? this._getEntityKey()._value._current.value : null;\r\n }\r\n\r\n /**\r\n * Set new datastream value\r\n * \r\n * @param {!string} _id - Datastream identifier\r\n * @param {!objecr} val - Datastream value. If this value is null then datastream value will be removed.\r\n */\r\n with(_id, val) {\r\n if (val === undefined || val.length === 0) {\r\n delete this._entity[_id];\r\n return this;\r\n }\r\n if (this.getAllowedDatastreams().filter(function(ds) {\r\n return ds.identifier === _id;\r\n }).length !== 1) {\r\n console.warn('Datastream not found or operations can not be performed on it. This value will be ignored. Datastream Name: ' + _id);\r\n return this;\r\n }\r\n this._entity[_id] = {\r\n '_value': {\r\n '_current': {\r\n 'value': val\r\n }\r\n }\r\n };\r\n return this;\r\n }\r\n\r\n /**\r\n * @return {array} - Allowed Datastream definition array\r\n */\r\n getAllowedDatastreams() {\r\n return this._allowedDatastreams;\r\n }\r\n\r\n initFromFlattened(_flattenedEntityData) {\r\n let _this = this;\r\n if (_flattenedEntityData && Object.keys(_flattenedEntityData).length > 0) {\r\n Object.keys(_flattenedEntityData).forEach(function(_id) {\r\n if (_id.toLowerCase().startsWith(\"provision\")) {\r\n var _content = _flattenedEntityData[_id];\r\n if (Array.isArray(_content)) {\r\n _content = _content[0];\r\n }\r\n _this.with(_id, _content._value._current.value);\r\n }\r\n });\r\n }\r\n }\r\n\r\n _initFromJson(_jsonEntityData, _path) {\r\n let _this = this;\r\n if (_jsonEntityData) {\r\n var keys = Object.keys(_jsonEntityData);\r\n keys.forEach(function(key) {\r\n var obj = _jsonEntityData[key];\r\n var _current = obj._current;\r\n var path = _path ? (_path + '.' + key) : key;\r\n if (_current) {\r\n _this.with(path, _current.value);\r\n } else {\r\n if (Array.isArray(obj)) {\r\n _this._initFromJson(obj[0], path + '[]');\r\n } else {\r\n _this._initFromJson(obj, path);\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n initFromJson(_jsonEntityData) {\r\n let _this = this;\r\n var provision = {};\r\n if (_jsonEntityData && (provision = _jsonEntityData.provision)) {\r\n _this._initFromJson(provision, 'provision');\r\n }\r\n }\r\n\r\n /**\r\n * This invoke a request to OpenGate North API and the callback is managed by promises\r\n * This function deletes a entity of provision\r\n * @return {Promise}\r\n * @property {function (result:object, statusCode:number)} then - When request it is OK\r\n * @property {function (error:string)} catch - When request it is NOK\r\n */\r\n deleteAll() {\r\n let defered = q.defer();\r\n let promise = defered.promise;\r\n this._setUrlParameters({\r\n full: true\r\n });\r\n this._ogapi.Napi.delete(this._buildURL(), this._timeout, this._getExtraHeaders(), this._getUrlParameters())\r\n .then((res) => {\r\n if (res.statusCode === HttpStatus.OK) {\r\n defered.resolve({\r\n statusCode: res.statusCode\r\n });\r\n } else {\r\n defered.reject({\r\n errors: res.errors,\r\n statusCode: res.statusCode\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n defered.reject(error);\r\n });\r\n return promise;\r\n }\r\n\r\n /**\r\n * This invoke a request to OpenGate North API and the callback is managed by promises\r\n * This function updates a entity of provision\r\n * @return {Promise}\r\n * @property {function (result:object, statusCode:number)} then - When request it is OK\r\n * @property {function (error:string)} catch - When request it is NOK\r\n * @example\r\n * ogapi.organizationsBuilder().update()\r\n */\r\n update() {\r\n var defered = q.defer();\r\n var promise = defered.promise;\r\n\r\n this._ogapi.Napi.put(this._buildURL(), this._composeUpdateElement(), this._timeout, this._getExtraHeaders(), this._getUrlParameters())\r\n .then((res) => {\r\n if (res.statusCode === 200) {\r\n defered.resolve({\r\n statusCode: res.statusCode\r\n });\r\n } else if (res.status === 200) {\r\n defered.resolve({\r\n statusCode: res.status\r\n });\r\n } else {\r\n defered.reject({\r\n errors: res.errors,\r\n statusCode: res.statusCode\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n defered.reject(error);\r\n });\r\n return promise;\r\n }\r\n\r\n /**\r\n * This invoke a request to OpenGate North API and the callback is managed by promises\r\n * This function patch a entity of provision\r\n * @return {Promise}\r\n * @property {function (result:object, statusCode:number)} then - When request it is OK\r\n * @property {function (error:string)} catch - When request it is NOK\r\n * @example\r\n * ogapi.organizationsBuilder().update()\r\n */\r\n patch() {\r\n var defered = q.defer();\r\n var promise = defered.promise;\r\n\r\n this._ogapi.Napi.patch(this._buildURL(), this._composeUpdateElement(), this._timeout, this._getExtraHeaders(), this._getUrlParameters())\r\n .then((res) => {\r\n if (res.statusCode === 200) {\r\n defered.resolve({\r\n statusCode: res.statusCode\r\n });\r\n } else if (res.status === 200) {\r\n defered.resolve({\r\n statusCode: res.status\r\n });\r\n } else {\r\n defered.reject({\r\n errors: res.errors,\r\n statusCode: res.statusCode\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n defered.reject(error);\r\n });\r\n return promise;\r\n }\r\n}",
|
|
40487
|
+
"content": "'use strict';\r\n\r\nimport HttpStatus from 'http-status-codes';\r\nimport BaseProvision from '../BaseProvision';\r\nimport q from 'q';\r\nimport _ from 'lodash'\r\n\r\nconst ERROR_VALUE_NOT_ALLOWED = 'value is not allowed. The value should be formatted as follows: ';\r\nconst ERROR_DATASTREAM_NOT_ALLOWED = 'Datastream is not allowed';\r\nconst schema_base = '/og_basic_types.json';\r\n\r\n/**\r\n * This class allow set simple values.\r\n */\r\nexport default class SimpleBuilder extends BaseProvision {\r\n\r\n /**\r\n * @param {!InternalOpenGateAPI} ogapi - this is ogapi instance\r\n * @param {!string} resource - this is the resource url where can be create/delete/update/read the entity\r\n * @param {!array} [allowedDatastreams] - Allowed datastreams to add into the new entity\r\n * @param {!array} [definedSchemas] - Jsonschema about all OpenGate specific types\r\n * @param {!Validator} [jsonSchemaValidator] - Json schema validator tool\r\n */\r\n constructor(ogapi, resource, allowedDatastreams, definedSchemas, jsonSchemaValidator, timeout) {\r\n super(ogapi, \"/organizations/\" + resource, timeout);\r\n if (typeof this._getEntityKey !== \"function\") {\r\n throw new Error(\"Must override method: _getEntityKey\");\r\n }\r\n this._setUrlParameters({\r\n flattened: true\r\n });\r\n this._entity = {};\r\n this._allowedDatastreams = allowedDatastreams;\r\n this._definedSchemas = definedSchemas;\r\n this._jsonSchemaValidator = jsonSchemaValidator;\r\n }\r\n\r\n _buildURL() {\r\n return this._resource + \"/\" + this.getEntityKey();\r\n }\r\n\r\n _validate() {\r\n let _this = this;\r\n let errors = [];\r\n Object.keys(this._entity).forEach(function(_id) {\r\n if (_id != 'resourceType') {\r\n if (!_this._definedSchemas[_id]) {\r\n throw new Error(ERROR_DATASTREAM_NOT_ALLOWED + ': ' + _id);\r\n }\r\n let jSchema = _this._definedSchemas[_id].value;\r\n if (_this._entity[_id].constructor === Array) {\r\n _this._entity[_id].forEach(function(item) {\r\n let value = item._value._current.value;\r\n if (!_this._jsonSchemaValidator.validate(schema_base, value)) {\r\n errors.push(_id + ' [' + value + '] ' + ERROR_VALUE_NOT_ALLOWED + JSON.stringify(jSchema));\r\n }\r\n });\r\n } else {\r\n let value = _this._entity[_id]._value._current.value;\r\n if (!_this._jsonSchemaValidator.validate(schema_base, value)) {\r\n errors.push(_id + ' [' + value + '] ' + ERROR_VALUE_NOT_ALLOWED + JSON.stringify(jSchema));\r\n }\r\n }\r\n }\r\n });\r\n\r\n if (errors.length > 0) {\r\n throw new Error(JSON.stringify(errors).replace(new RegExp(\"\\\"\", 'g'), \"\"));\r\n }\r\n }\r\n\r\n _composeElement() {\r\n this._validate();\r\n return this._entity;\r\n }\r\n\r\n /**\r\n * @return {string} - Entity identifier\r\n */\r\n getEntityKey() {\r\n return (this._getEntityKey() !== null) ? this._getEntityKey()._value._current.value : null;\r\n }\r\n\r\n /**\r\n * Set new datastream value\r\n * \r\n * @param {!string} _id - Datastream identifier\r\n * @param {!objecr} val - Datastream value. If this value is null then datastream value will be removed.\r\n */\r\n with(_id, val) {\r\n if (val === undefined || val.length === 0) {\r\n // Si es un array vacío debe continuar\r\n if (!_.isArray(val)) {\r\n delete this._entity[_id];\r\n return this;\r\n }\r\n }\r\n\r\n if (this.getAllowedDatastreams().filter(function(ds) {\r\n return ds.identifier === _id;\r\n }).length !== 1) {\r\n console.warn('Datastream not found or operations can not be performed on it. This value will be ignored. Datastream Name: ' + _id);\r\n return this;\r\n }\r\n this._entity[_id] = {\r\n '_value': {\r\n '_current': {\r\n 'value': val\r\n }\r\n }\r\n };\r\n return this;\r\n }\r\n\r\n /**\r\n * @return {array} - Allowed Datastream definition array\r\n */\r\n getAllowedDatastreams() {\r\n return this._allowedDatastreams;\r\n }\r\n\r\n initFromFlattened(_flattenedEntityData) {\r\n let _this = this;\r\n if (_flattenedEntityData && Object.keys(_flattenedEntityData).length > 0) {\r\n Object.keys(_flattenedEntityData).forEach(function(_id) {\r\n if (_id.toLowerCase().startsWith(\"provision\")) {\r\n var _content = _flattenedEntityData[_id];\r\n if (Array.isArray(_content)) {\r\n _content = _content[0];\r\n }\r\n _this.with(_id, _content._value._current.value);\r\n }\r\n });\r\n }\r\n }\r\n\r\n _initFromJson(_jsonEntityData, _path) {\r\n let _this = this;\r\n if (_jsonEntityData) {\r\n var keys = Object.keys(_jsonEntityData);\r\n keys.forEach(function(key) {\r\n var obj = _jsonEntityData[key];\r\n var _current = obj._current;\r\n var path = _path ? (_path + '.' + key) : key;\r\n if (_current) {\r\n _this.with(path, _current.value);\r\n } else {\r\n if (Array.isArray(obj)) {\r\n _this._initFromJson(obj[0], path + '[]');\r\n } else {\r\n _this._initFromJson(obj, path);\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n initFromJson(_jsonEntityData) {\r\n let _this = this;\r\n var provision = {};\r\n if (_jsonEntityData && (provision = _jsonEntityData.provision)) {\r\n _this._initFromJson(provision, 'provision');\r\n }\r\n }\r\n\r\n /**\r\n * This invoke a request to OpenGate North API and the callback is managed by promises\r\n * This function deletes a entity of provision\r\n * @return {Promise}\r\n * @property {function (result:object, statusCode:number)} then - When request it is OK\r\n * @property {function (error:string)} catch - When request it is NOK\r\n */\r\n deleteAll() {\r\n let defered = q.defer();\r\n let promise = defered.promise;\r\n this._setUrlParameters({\r\n full: true\r\n });\r\n this._ogapi.Napi.delete(this._buildURL(), this._timeout, this._getExtraHeaders(), this._getUrlParameters())\r\n .then((res) => {\r\n if (res.statusCode === HttpStatus.OK) {\r\n defered.resolve({\r\n statusCode: res.statusCode\r\n });\r\n } else {\r\n defered.reject({\r\n errors: res.errors,\r\n statusCode: res.statusCode\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n defered.reject(error);\r\n });\r\n return promise;\r\n }\r\n\r\n /**\r\n * This invoke a request to OpenGate North API and the callback is managed by promises\r\n * This function updates a entity of provision\r\n * @return {Promise}\r\n * @property {function (result:object, statusCode:number)} then - When request it is OK\r\n * @property {function (error:string)} catch - When request it is NOK\r\n * @example\r\n * ogapi.organizationsBuilder().update()\r\n */\r\n update() {\r\n var defered = q.defer();\r\n var promise = defered.promise;\r\n\r\n this._ogapi.Napi.put(this._buildURL(), this._composeUpdateElement(), this._timeout, this._getExtraHeaders(), this._getUrlParameters())\r\n .then((res) => {\r\n if (res.statusCode === 200) {\r\n defered.resolve({\r\n statusCode: res.statusCode\r\n });\r\n } else if (res.status === 200) {\r\n defered.resolve({\r\n statusCode: res.status\r\n });\r\n } else {\r\n defered.reject({\r\n errors: res.errors,\r\n statusCode: res.statusCode\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n defered.reject(error);\r\n });\r\n return promise;\r\n }\r\n\r\n /**\r\n * This invoke a request to OpenGate North API and the callback is managed by promises\r\n * This function patch a entity of provision\r\n * @return {Promise}\r\n * @property {function (result:object, statusCode:number)} then - When request it is OK\r\n * @property {function (error:string)} catch - When request it is NOK\r\n * @example\r\n * ogapi.organizationsBuilder().update()\r\n */\r\n patch() {\r\n var defered = q.defer();\r\n var promise = defered.promise;\r\n\r\n this._ogapi.Napi.patch(this._buildURL(), this._composeUpdateElement(), this._timeout, this._getExtraHeaders(), this._getUrlParameters())\r\n .then((res) => {\r\n if (res.statusCode === 200) {\r\n defered.resolve({\r\n statusCode: res.statusCode\r\n });\r\n } else if (res.status === 200) {\r\n defered.resolve({\r\n statusCode: res.status\r\n });\r\n } else {\r\n defered.reject({\r\n errors: res.errors,\r\n statusCode: res.statusCode\r\n });\r\n }\r\n })\r\n .catch((error) => {\r\n defered.reject(error);\r\n });\r\n return promise;\r\n }\r\n}",
|
|
40488
40488
|
"static": true,
|
|
40489
40489
|
"longname": "src/provision/entities/SimpleBuilder.js",
|
|
40490
40490
|
"access": null,
|
|
@@ -40503,7 +40503,7 @@
|
|
|
40503
40503
|
"importPath": "opengate-js/src/provision/entities/SimpleBuilder.js",
|
|
40504
40504
|
"importStyle": null,
|
|
40505
40505
|
"description": null,
|
|
40506
|
-
"lineNumber":
|
|
40506
|
+
"lineNumber": 8,
|
|
40507
40507
|
"undocument": true,
|
|
40508
40508
|
"unknown": [
|
|
40509
40509
|
{
|
|
@@ -40529,7 +40529,7 @@
|
|
|
40529
40529
|
"importPath": "opengate-js/src/provision/entities/SimpleBuilder.js",
|
|
40530
40530
|
"importStyle": null,
|
|
40531
40531
|
"description": null,
|
|
40532
|
-
"lineNumber":
|
|
40532
|
+
"lineNumber": 9,
|
|
40533
40533
|
"undocument": true,
|
|
40534
40534
|
"unknown": [
|
|
40535
40535
|
{
|
|
@@ -40555,7 +40555,7 @@
|
|
|
40555
40555
|
"importPath": "opengate-js/src/provision/entities/SimpleBuilder.js",
|
|
40556
40556
|
"importStyle": null,
|
|
40557
40557
|
"description": null,
|
|
40558
|
-
"lineNumber":
|
|
40558
|
+
"lineNumber": 10,
|
|
40559
40559
|
"undocument": true,
|
|
40560
40560
|
"unknown": [
|
|
40561
40561
|
{
|
|
@@ -40581,7 +40581,7 @@
|
|
|
40581
40581
|
"importPath": "opengate-js/src/provision/entities/SimpleBuilder.js",
|
|
40582
40582
|
"importStyle": "SimpleBuilder",
|
|
40583
40583
|
"description": "This class allow set simple values.",
|
|
40584
|
-
"lineNumber":
|
|
40584
|
+
"lineNumber": 15,
|
|
40585
40585
|
"interface": false,
|
|
40586
40586
|
"extends": [
|
|
40587
40587
|
"src/provision/BaseProvision.js~BaseProvision"
|
|
@@ -40598,7 +40598,7 @@
|
|
|
40598
40598
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#constructor",
|
|
40599
40599
|
"access": null,
|
|
40600
40600
|
"description": "",
|
|
40601
|
-
"lineNumber":
|
|
40601
|
+
"lineNumber": 24,
|
|
40602
40602
|
"params": [
|
|
40603
40603
|
{
|
|
40604
40604
|
"nullable": false,
|
|
@@ -40661,7 +40661,7 @@
|
|
|
40661
40661
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_entity",
|
|
40662
40662
|
"access": null,
|
|
40663
40663
|
"description": null,
|
|
40664
|
-
"lineNumber":
|
|
40664
|
+
"lineNumber": 32,
|
|
40665
40665
|
"undocument": true,
|
|
40666
40666
|
"unknown": [
|
|
40667
40667
|
{
|
|
@@ -40684,7 +40684,7 @@
|
|
|
40684
40684
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_allowedDatastreams",
|
|
40685
40685
|
"access": null,
|
|
40686
40686
|
"description": null,
|
|
40687
|
-
"lineNumber":
|
|
40687
|
+
"lineNumber": 33,
|
|
40688
40688
|
"undocument": true,
|
|
40689
40689
|
"unknown": [
|
|
40690
40690
|
{
|
|
@@ -40707,7 +40707,7 @@
|
|
|
40707
40707
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_definedSchemas",
|
|
40708
40708
|
"access": null,
|
|
40709
40709
|
"description": null,
|
|
40710
|
-
"lineNumber":
|
|
40710
|
+
"lineNumber": 34,
|
|
40711
40711
|
"undocument": true,
|
|
40712
40712
|
"unknown": [
|
|
40713
40713
|
{
|
|
@@ -40730,7 +40730,7 @@
|
|
|
40730
40730
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_jsonSchemaValidator",
|
|
40731
40731
|
"access": null,
|
|
40732
40732
|
"description": null,
|
|
40733
|
-
"lineNumber":
|
|
40733
|
+
"lineNumber": 35,
|
|
40734
40734
|
"undocument": true,
|
|
40735
40735
|
"unknown": [
|
|
40736
40736
|
{
|
|
@@ -40755,7 +40755,7 @@
|
|
|
40755
40755
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_buildURL",
|
|
40756
40756
|
"access": null,
|
|
40757
40757
|
"description": null,
|
|
40758
|
-
"lineNumber":
|
|
40758
|
+
"lineNumber": 38,
|
|
40759
40759
|
"undocument": true,
|
|
40760
40760
|
"unknown": [
|
|
40761
40761
|
{
|
|
@@ -40781,7 +40781,7 @@
|
|
|
40781
40781
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_validate",
|
|
40782
40782
|
"access": null,
|
|
40783
40783
|
"description": null,
|
|
40784
|
-
"lineNumber":
|
|
40784
|
+
"lineNumber": 42,
|
|
40785
40785
|
"undocument": true,
|
|
40786
40786
|
"unknown": [
|
|
40787
40787
|
{
|
|
@@ -40802,7 +40802,7 @@
|
|
|
40802
40802
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_composeElement",
|
|
40803
40803
|
"access": null,
|
|
40804
40804
|
"description": null,
|
|
40805
|
-
"lineNumber":
|
|
40805
|
+
"lineNumber": 72,
|
|
40806
40806
|
"undocument": true,
|
|
40807
40807
|
"unknown": [
|
|
40808
40808
|
{
|
|
@@ -40828,7 +40828,7 @@
|
|
|
40828
40828
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#getEntityKey",
|
|
40829
40829
|
"access": null,
|
|
40830
40830
|
"description": "",
|
|
40831
|
-
"lineNumber":
|
|
40831
|
+
"lineNumber": 80,
|
|
40832
40832
|
"params": [],
|
|
40833
40833
|
"return": {
|
|
40834
40834
|
"nullable": null,
|
|
@@ -40850,7 +40850,7 @@
|
|
|
40850
40850
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#with",
|
|
40851
40851
|
"access": null,
|
|
40852
40852
|
"description": "Set new datastream value",
|
|
40853
|
-
"lineNumber":
|
|
40853
|
+
"lineNumber": 90,
|
|
40854
40854
|
"params": [
|
|
40855
40855
|
{
|
|
40856
40856
|
"nullable": false,
|
|
@@ -40890,7 +40890,7 @@
|
|
|
40890
40890
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#getAllowedDatastreams",
|
|
40891
40891
|
"access": null,
|
|
40892
40892
|
"description": "",
|
|
40893
|
-
"lineNumber":
|
|
40893
|
+
"lineNumber": 118,
|
|
40894
40894
|
"params": [],
|
|
40895
40895
|
"return": {
|
|
40896
40896
|
"nullable": null,
|
|
@@ -40912,7 +40912,7 @@
|
|
|
40912
40912
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#initFromFlattened",
|
|
40913
40913
|
"access": null,
|
|
40914
40914
|
"description": null,
|
|
40915
|
-
"lineNumber":
|
|
40915
|
+
"lineNumber": 122,
|
|
40916
40916
|
"undocument": true,
|
|
40917
40917
|
"unknown": [
|
|
40918
40918
|
{
|
|
@@ -40940,7 +40940,7 @@
|
|
|
40940
40940
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#_initFromJson",
|
|
40941
40941
|
"access": null,
|
|
40942
40942
|
"description": null,
|
|
40943
|
-
"lineNumber":
|
|
40943
|
+
"lineNumber": 137,
|
|
40944
40944
|
"undocument": true,
|
|
40945
40945
|
"unknown": [
|
|
40946
40946
|
{
|
|
@@ -40974,7 +40974,7 @@
|
|
|
40974
40974
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#initFromJson",
|
|
40975
40975
|
"access": null,
|
|
40976
40976
|
"description": null,
|
|
40977
|
-
"lineNumber":
|
|
40977
|
+
"lineNumber": 158,
|
|
40978
40978
|
"undocument": true,
|
|
40979
40979
|
"unknown": [
|
|
40980
40980
|
{
|
|
@@ -41002,7 +41002,7 @@
|
|
|
41002
41002
|
"longname": "src/provision/entities/SimpleBuilder.js~SimpleBuilder#deleteAll",
|
|
41003
41003
|
"access": null,
|
|
41004
41004
|
"description": "This invoke a request to OpenGate North API and the callback is managed by promises\nThis function deletes a entity of provision",
|
|
41005
|
-
"lineNumber":
|
|
41005
|
+
"lineNumber": 173,
|
|
41006
41006
|
"params": [],
|
|
41007
41007
|
"properties": [
|
|
41008
41008
|
{
|
|
@@ -41049,7 +41049,7 @@
|
|
|
41049
41049
|
"examples": [
|
|
41050
41050
|
" ogapi.organizationsBuilder().update()"
|
|
41051
41051
|
],
|
|
41052
|
-
"lineNumber":
|
|
41052
|
+
"lineNumber": 207,
|
|
41053
41053
|
"params": [],
|
|
41054
41054
|
"properties": [
|
|
41055
41055
|
{
|
|
@@ -41096,7 +41096,7 @@
|
|
|
41096
41096
|
"examples": [
|
|
41097
41097
|
" ogapi.organizationsBuilder().update()"
|
|
41098
41098
|
],
|
|
41099
|
-
"lineNumber":
|
|
41099
|
+
"lineNumber": 243,
|
|
41100
41100
|
"params": [],
|
|
41101
41101
|
"properties": [
|
|
41102
41102
|
{
|
|
@@ -270,6 +270,7 @@
|
|
|
270
270
|
import HttpStatus from 'http-status-codes';
|
|
271
271
|
import BaseProvision from '../BaseProvision';
|
|
272
272
|
import q from 'q';
|
|
273
|
+
import _ from 'lodash'
|
|
273
274
|
|
|
274
275
|
const ERROR_VALUE_NOT_ALLOWED = 'value is not allowed. The value should be formatted as follows: ';
|
|
275
276
|
const ERROR_DATASTREAM_NOT_ALLOWED = 'Datastream is not allowed';
|
|
@@ -355,9 +356,13 @@ export default class SimpleBuilder extends BaseProvision {
|
|
|
355
356
|
*/
|
|
356
357
|
with(_id, val) {
|
|
357
358
|
if (val === undefined || val.length === 0) {
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
// Si es un array vacío debe continuar
|
|
360
|
+
if (!_.isArray(val)) {
|
|
361
|
+
delete this._entity[_id];
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
360
364
|
}
|
|
365
|
+
|
|
361
366
|
if (this.getAllowedDatastreams().filter(function(ds) {
|
|
362
367
|
return ds.identifier === _id;
|
|
363
368
|
}).length !== 1) {
|