diff --git a/process/WsValidation_lib/process.js b/process/WsValidation_lib/process.js index 5829c6958831028e192681793c1c4f121e32e3c2..7028a04ba76cf4b749262e485fec1ab607dd3503 100644 --- a/process/WsValidation_lib/process.js +++ b/process/WsValidation_lib/process.js @@ -215,6 +215,8 @@ WsValidationType.get = function(pKey) this.additionalInfo.user = project.getPreferenceValue("custom." + this.webserviceName + ".user"); if (!this.additionalInfo.password) this.additionalInfo.password = project.getPreferenceValue("custom." + this.webserviceName + ".pw"); + if (this.additionalInfo.resultLimit === undefined) //can be explicitly null + this.additionalInfo.resultLimit = project.getPreferenceValue("custom." + this.webserviceName + ".resultLimit"); if (!this.additionalInfo.url) throw new Error("if the webservice '" + this.key + "' is enabled, you have to provide the url"); @@ -227,6 +229,9 @@ WsValidationType.get = function(pKey) if (this.additionalInfo.user && this.additionalInfo.password) nominatimRequest.setUser(this.additionalInfo.user, this.additionalInfo.password); + + if (this.additionalInfo.resultLimit) + nominatimRequest.setResultLimit(this.additionalInfo.resultLimit); // call webservice var ret = nominatimRequest.get(); @@ -506,6 +511,9 @@ WsValidationFieldUtils.wsOnValueChangeProcess = function(pWsType, pMainField) } } +/** + * Object for handling nominatim requests + */ function NominatimRequest (pUrl) { this.url = pUrl; @@ -516,6 +524,12 @@ function NominatimRequest (pUrl) }; } +/** + * Changes if additional address details should be loaded. + * + * @param {boolean} [pInclude=true] if the details should be included + * @return {NominatimRequest} current object + */ NominatimRequest.prototype.includeAddressDetails = function (pInclude) { if (pInclude === false) @@ -525,6 +539,13 @@ NominatimRequest.prototype.includeAddressDetails = function (pInclude) return this; } +/** + * Changes the user for the webservice auth. + * + * @param {String} pUser the username + * @param {String} pPassword the password of the user + * @return {NominatimRequest} current object + */ NominatimRequest.prototype.setUser = function (pUser, pPassword) { this.user = pUser; @@ -532,18 +553,35 @@ NominatimRequest.prototype.setUser = function (pUser, pPassword) return this; } +/** + * Adds parameters to the request. + * + * @param {Object} pParameters object containing the parameters that should be set + * @return {NominatimRequest} current object + */ NominatimRequest.prototype.setParameters = function (pParameters) { Object.assign(this.parameters, pParameters); return this; } +/** + * Sets the result limit of the request. + * + * @param {Number} pLimit the max amount of rows the webservice should return (default is 10, max is 50) + * @return {NominatimRequest} current object + */ NominatimRequest.prototype.setResultLimit = function (pLimit) { this.parameters.limit = pLimit.toString(); return this; } +/** + * Calls the webservice and returns the result. + * + * @return {Object} webservice result + */ NominatimRequest.prototype.get = function () { var restConf = net.createConfigForRestWebserviceCall()