diff --git a/.eslintrc.json b/.eslintrc.json
index 21e0614..b2c4a71 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -7,8 +7,9 @@
"env": {
"browser": true,
"es6": true,
- "node": true
- },
+ "node": true,
+ "mocha": true
+ },
"rules": {
"indent": 1,
"no-console": 0,
diff --git a/.gitignore b/.gitignore
index b00f58d..2f350c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,12 @@
.DS_Store
.vscode
+package-lock.json
tmp
tslint.json
+node_modules/
+scratch1/
+scratch2/
+build/
+packages/ng-datasource/package-lock.json
+
+**/tsFiles
\ No newline at end of file
diff --git a/contributing.md b/contributing.md
index b48f24c..9b3fe1f 100644
--- a/contributing.md
+++ b/contributing.md
@@ -40,7 +40,7 @@ Notwithstanding the above, we reserve the right to ask you to sign a GitHub for an open or closed Pull Request that relates to your submission.
* Clone the repository.
```bash
- git clone git@github.com:CloudDataObject/JSDO.git
+ git clone git@github.com:progress/JSDO.git -b develop
```
* Initialize the submodule.
```bash
@@ -50,20 +50,25 @@ Notwithstanding the above, we reserve the right to ask you to sign a Gitflow branching model so you will have to branch from our develop branch.
+* Make your changes in a new `git` branch. We use the Gitflow branching model.
* Commit your changes and create a descriptive commit message (the commit message is used to generate release notes).
```bash
git commit -a
```
+* Ensure your changes pass the Mocha tests for the JSDO.
+```bash
+ npm install
+ npm test
+```
* Push your branch to GitHub.
```bash
git push origin my-fix-branch
```
-* In GitHub, send a Pull Request to JSDO:master.
+* In GitHub, send a Pull Request to JSDO:develop.
* If we suggest changes, you can modify your branch, rebase, and force a new push to your GitHub repository to update the Pull Request.
```bash
- git rebase master -i
+ git rebase develop -i
git push -f
```
@@ -77,7 +82,7 @@ When the patch is reviewed and merged, you can safely delete your branch and pul
```
* Check out the develop branch.
```bash
- git checkout master -f
+ git checkout develop -f
```
* Delete the local branch.
```bash
@@ -85,7 +90,7 @@ When the patch is reviewed and merged, you can safely delete your branch and pul
```
* Update your develop branch with the latest upstream version.
```
- git pull --ff upstream master
+ git pull --ff upstream develop
```
[Back to Top][1]
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..f195391
--- /dev/null
+++ b/index.html
@@ -0,0 +1,500 @@
+
+
+
+ Mocha
+
+
+
+
+
+
+
+
show failures only
+
+
+
passes: 1
+
pending: 0
+
failures: 0
+
duration: 1.3s
+
+
+
Smoke Tests
Ping Test
should have a successful connection to the backend39ms
session.ping().then((object) => {
+ // If we have successfully logged into the backend, the result
+ // of our ping() should be true
+ expect(object.result).to.be.true;
+}).then(done, done);
+
+
+
+
diff --git a/lib/progress.all.js b/lib/progress.all.js
index 8ed4175..9723ab0 100644
--- a/lib/progress.all.js
+++ b/lib/progress.all.js
@@ -1,5 +1,5 @@
/*
-Progress JSDO Version: 5.0.0
+Progress JSDO Version: 6.0.0
Copyright 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -18,7 +18,7 @@ limitations under the License.
/*eslint no-global-assign: ["error", {"exceptions": ["localStorage"]}]*/
/*global XMLHttpRequest:true, require, console, localStorage:true, sessionStorage:true, $:true, Promise, setTimeout */
/*
-progress.util.js Version: 5.0.0
+progress.util.js Version: 6.0.0
Copyright (c) 2014-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -63,7 +63,8 @@ limitations under the License.
var pkg_xmlhttprequest = "xmlhttprequest",
pkg_nodeLocalstorage = "node-localstorage",
pkg_nativescriptLocalstorage = "nativescript-localstorage",
- pkg_fileSystemAccess = "file-system/file-system-access"
+ pkg_fileSystemAccess = "file-system/file-system-access",
+ pkg_base64 = "base-64"
;
// If XMLHttpRequest is undefined, enviroment would appear to be Node.js
@@ -114,7 +115,7 @@ limitations under the License.
// load module base-64
try {
if (typeof btoa === "undefined") {
- btoa = require("base-64").encode;
+ btoa = require("" + pkg_base64).encode;
}
} catch(exception3) {
console.error("Error: JSDO library requires btoa() function in NativeScript.\n"
@@ -144,7 +145,7 @@ limitations under the License.
// load module base-64
try {
if (typeof btoa === "undefined") {
- btoa = require("base-64").encode;
+ btoa = require("" + pkg_base64).encode;
}
} catch(exception3) {
console.error("Error: JSDO library requires btoa() function in Node.js.\n"
@@ -276,27 +277,28 @@ limitations under the License.
object.result = arg2;
object.info = arg3;
} else {
- objectName = arg1.constructor.name.toLowerCase();
- if (!objectName) {
+ // Map some object name to use a particular property name
+ // We should probably spend some time down the line to truly use
+ // ES6 promises.
+ if (arg1 instanceof progress.data.JSDOSession) {
+ objectName = "jsdosession";
+ } else if (arg1 instanceof progress.data.AuthenticationProvider) {
+ objectName = "provider";
+ } else if (arg1 instanceof progress.data.JSDO) {
+ objectName = "jsdo";
+ } else if (typeof(arg1) === "number") {
+ objectName = "result";
+ } else {
objectName = typeof(arg1);
}
- // Map some object name to use a particular property name
- switch (objectName) {
- case "authenticationprovider":
- objectName = "provider"
- break;
- case "number":
- objectName = "result"
- break;
- default:
- break;
- }
object[objectName] = arg1;
if (objectName === "jsdo") {
object.success = arg2;
if (arg3 && arg3.xhr) {
object.request = arg3;
+ } else if (arg3 && arg3.batch) {
+ object.request = arg3;
} else {
object.info = arg3;
}
@@ -719,7 +721,7 @@ limitations under the License.
format = "'{1}'";
value = value.replace(/'/g, "~'");
} else if (type === DATE_OBJECT_TYPE) {
- ablType = tableRef._getABLType(field);
+ ablType = tableRef._getABLType(filter.field);
if (ablType === "DATE") {
format = "DATE({1:MM, dd, yyyy})";
} else if (ablType === "DATETIME-TZ") {
@@ -1093,7 +1095,7 @@ limitations under the License.
}());
//# sourceURL=progress.jsdo.js
/*
-progress.js Version: 5.0.0
+progress.js Version: 6.0.0
Copyright (c) 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -3319,6 +3321,11 @@ limitations under the License.
this._resource.idProperty = properties[tableName].idProperty;
}
}
+ } else if (this._resource.schema
+ && this._resource.schema.properties
+ && this._resource.schema.properties[tableName]
+ && this._resource.schema.properties[tableName].idProperty) {
+ this._resource.idProperty = this._resource.schema.properties[tableName].idProperty;
}
// Add functions for operations to JSDO object
@@ -8720,7 +8727,7 @@ limitations under the License.
//this is so that we can see the code in Chrome's Source tab when script is loaded via XHR
//# sourceURL=progress.jsdo.js
/*
-progress.session.js Version: 5.0.0
+progress.session.js Version: 6.0.0
Copyright (c) 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -13695,7 +13702,7 @@ if (typeof exports !== "undefined") {
//# sourceURL=progress.jsdo.js
/*
-progress.auth.js Version: 4.4.0-3
+progress.auth.js Version: 6.0.0
Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -14166,7 +14173,7 @@ limitations under the License.
//# sourceURL=progress.jsdo.js
/*
-progress.auth.basic.js Version: 4.4.0-3
+progress.auth.basic.js Version: 6.0.0
Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -14325,7 +14332,7 @@ limitations under the License.
}());
//# sourceURL=progress.jsdo.js
/*
-progress.auth.form.js Version: 5.0.0
+progress.auth.form.js Version: 6.0.0
Copyright (c) 2016-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -14537,7 +14544,7 @@ limitations under the License.
}());
//# sourceURL=progress.jsdo.js
/*
-progress.auth.sso.js Version: 4.4.0-3
+progress.auth.sso.js Version: 6.0.0
Copyright (c) 2016-2017 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -15031,7 +15038,7 @@ limitations under the License.
/*
-progress.data.kendo.js Version: 5.0.0
+progress.data.kendo.js Version: 6.0.0
Copyright (c) 2015-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -15286,6 +15293,8 @@ if (typeof (kendo) !== "undefined") {
elementName,
copy;
+ // Remove prods:rowState property from data object
+ delete data["prods:rowState"];
if (!transport.useArrays && transport._convertTypes && (transport._convertFields._arrayFields.length > 0)) {
copy = {};
transport.jsdo._copyRecord(transport.jsdo._buffers[transport.tableRef], data, copy);
@@ -15387,6 +15396,10 @@ if (typeof (kendo) !== "undefined") {
}
}
}
+
+ if (transport.jsdo._resource.idProperty) {
+ fields[transport.jsdo._resource.idProperty].editable = false;
+ }
return fields;
},
_getInitialValues: function () {
@@ -15615,14 +15628,17 @@ if (typeof (kendo) !== "undefined") {
if (options.batch) {
array = [];
if (options.data.created instanceof Array) {
- for (i = 0; i < options.data.created.length; i += 1) {
- jsrecord = jsdo[transport.tableRef].findById(
- options.data.created[i]._id
- );
- if (jsrecord) {
- record = transport._convertDataTypes(jsrecord.data);
- array.push(record);
- } else if (jsdo.autoApplyChanges) {
+ // Process changes for idProperty case
+ if (jsdo._resource.idProperty) {
+ if (request.jsrecords) {
+ for (i = 0; i < request.jsrecords.length; i += 1) {
+ if (request.jsrecords[i].data["prods:rowState"] === "created") {
+ record = transport._convertDataTypes(request.jsrecords[i].data);
+ array.push(record);
+ }
+ }
+ }
+ if (options.data.created.length !== array.length) {
options.error(
null,
null,
@@ -15630,6 +15646,23 @@ if (typeof (kendo) !== "undefined") {
);
return;
}
+ } else {
+ for (i = 0; i < options.data.created.length; i += 1) {
+ jsrecord = jsdo[transport.tableRef].findById(
+ options.data.created[i]._id
+ );
+ if (jsrecord) {
+ record = transport._convertDataTypes(jsrecord.data);
+ array.push(record);
+ } else if (jsdo.autoApplyChanges) {
+ options.error(
+ null,
+ null,
+ new Error("Created record was not found in memory.")
+ );
+ return;
+ }
+ }
}
}
options.success(array, "create");
@@ -15679,6 +15712,10 @@ if (typeof (kendo) !== "undefined") {
&& request.batch.operations instanceof Array
&& request.batch.operations.length === 1) {
id = request.batch.operations[0].jsrecord.data._id;
+ } else if (request
+ && request.jsrecords instanceof Array
+ && request.jsrecords.length === 1) {
+ id = request.jsrecords[0].data._id;
}
} else {
id = options.data._id;
@@ -15690,6 +15727,7 @@ if (typeof (kendo) !== "undefined") {
} else {
options.success({});
}
+
}
},
_saveChanges: function (options) {
diff --git a/lib/progress.all.min.js b/lib/progress.all.min.js
index 3b3691b..d37749a 100644
--- a/lib/progress.all.min.js
+++ b/lib/progress.all.min.js
@@ -1,5 +1,5 @@
/*
-Progress JSDO Version: 5.0.0
+Progress JSDO Version: 6.0.0
Copyright 2012-2018 Progress Software Corporation and/or its subsidiaries or affiliates.
@@ -15,5 +15,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
-(function(){var isNativeScript=false,isNodeJS=false;var pkg_xmlhttprequest="xmlhttprequest",pkg_nodeLocalstorage="node-localstorage",pkg_nativescriptLocalstorage="nativescript-localstorage",pkg_fileSystemAccess="file-system/file-system-access";if(typeof XMLHttpRequest==="undefined"){isNodeJS=true;try{XMLHttpRequest=require(""+pkg_xmlhttprequest).XMLHttpRequest}catch(e){console.error("Error: JSDO library requires XMLHttpRequest object in Node.js.\n"+"Please install xmlhttprequest package.")}}if(!isNodeJS&&(typeof localStorage==="undefined"||typeof sessionStorage==="undefined")){try{require(""+pkg_fileSystemAccess);isNativeScript=true}catch(exception1){isNativeScript=false}}if(isNativeScript){try{if(typeof sessionStorage==="undefined"){sessionStorage=require(""+pkg_nativescriptLocalstorage)}if(typeof localStorage==="undefined"){localStorage=require(""+pkg_nativescriptLocalstorage)}}catch(exception2){console.error("Error: JSDO library requires localStorage and sessionStorage objects in NativeScript.\n"+"Please install nativescript-localstorage package.")}try{if(typeof btoa==="undefined"){btoa=require("base-64").encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in NativeScript.\n"+"Please install base-64 package.")}}if(isNodeJS){var LocalStorage;if(typeof localStorage==="undefined"){try{var module=require(""+pkg_nodeLocalstorage);LocalStorage=module.LocalStorage;localStorage=new LocalStorage("./scratch1")}catch(e){console.error("Error: JSDO library requires localStorage and sessionStorage objects in Node.js.\n"+"Please install node-localstorage package.")}}if(typeof sessionStorage==="undefined"&&typeof LocalStorage!=="undefined"){sessionStorage=new LocalStorage("./scratch2")}try{if(typeof btoa==="undefined"){btoa=require("base-64").encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in Node.js.\n"+"Please install base-64 package.")}}})();(function(){if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.util={};var STRING_OBJECT_TYPE="String",DATE_OBJECT_TYPE="Date",CHARACTER_ABL_TYPE="CHARACTER";progress.util.Deferred=function(){function Deferred(){this._deferred={}}Deferred.prototype.promise=function(){var that=this;if(progress.util.Deferred.useJQueryPromises){if(typeof $!=="undefined"&&typeof $.Deferred==="function"){this._deferred._jQuerydeferred=$.Deferred();this._promise=this._deferred._jQuerydeferred.promise()}else{throw new Error("JQuery Promises not found in environment.")}}else{this._promise=new Promise(function(resolve,reject){that._deferred.resolve=resolve;that._deferred.reject=reject})}if(this._resolveArguments||this._rejectArguments){setTimeout(function(){if(that._resolveArguments){that.resolve.apply(that,that._resolveArguments)}else if(that._rejectArguments){that.reject.apply(that,that._rejectArguments)}},500)}return this._promise};Deferred.prototype.resolve=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.resolve.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.resolve(object)}}else{this._resolveArguments=arguments}};Deferred.prototype.reject=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.reject.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.reject(object)}}else{this._rejectArguments=arguments}};Deferred.useJQueryPromises=false;Deferred.when=function(deferreds){if(progress.util.Deferred.useJQueryPromises){return $.when.apply($,deferreds)}else{return Promise.all(deferreds)}};Deferred.getParamObject1=function(arg1,arg2,arg3){var object={},objectName;try{if(typeof arg1==="undefined"||arg1===null){object.result=arg2;object.info=arg3}else{objectName=arg1.constructor.name.toLowerCase();if(!objectName){objectName=typeof arg1}switch(objectName){case"authenticationprovider":objectName="provider";break;case"number":objectName="result";break;default:break}object[objectName]=arg1;if(objectName==="jsdo"){object.success=arg2;if(arg3&&arg3.xhr){object.request=arg3}else{object.info=arg3}}else{if(objectName==="result"){object.info=arg2;if(arg3){object.info2=arg3}}else{object.result=arg2;object.info=arg3}}}}catch(e){console.log("Error: Undetermined argument in getParamObject() call.")}return object};Deferred.getParamObject=function(arg1,arg2,arg3){var object={};if(progress.util.Deferred.useJQueryPromises){object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3)}else{if(typeof arg1==="undefined"){object.result=arg2;object.info=arg3;arg1=object}return arg1}return object};return Deferred}();progress.util.Observable=function(){function _filterObservers(observers,fn,scope,operation){return observers.filter(function(el){if(el.fn!==fn||el.scope!==scope||el.operation!==operation){return el}},this)}this.validateSubscribe=function(args,evt,listenerData){if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i'}else htmltext="";htmltext+='";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i'+'{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,defaultPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._pingtestOnReadyStateChange=function(){var xhr=this;if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}args.xhr=xhr};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,promise,authProviderInitObject={};function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){var jsdosession;try{jsdosession=new progress.data.JSDOSession(options);try{jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(e){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){loginHandler(authProvider)}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLoginResult(xhr,deferred)}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLogoutResult(xhr,deferred)}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){processRefreshResult(xhr,deferred)}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})();if(typeof kendo!=="undefined"){(function(){var JSDODataReader,JSDOTransport,JSDOObservable=new kendo.Observable;function initializeJSDO(transport,options){var jsdo,resourceName;if(options.jsdo instanceof progress.data.JSDO){jsdo=options.jsdo}else if(typeof options.jsdo==="string"){resourceName=options.jsdo;jsdo=new progress.data.JSDO({name:resourceName})}else{throw new Error("JSDO: jsdo property must be either a JSDO instance or a string.")}if(transport.tableRef===undefined&&jsdo._defaultTableRef){transport.tableRef=jsdo._defaultTableRef._name}if(transport.tableRef===undefined){throw new Error("JSDO: A tableRef must be specified when using a multi-table DataSet.")}else if(jsdo[transport.tableRef]===undefined){throw new Error("JSDO: tableRef '"+transport.tableRef+"' is not present in JSDO definition.")}return jsdo}JSDODataReader=kendo.data.readers.json.extend({init:function(arg1){var event={},transport;JSDOObservable.trigger("info",event);transport=this.transport=event.sender._events.info.transport;kendo.data.readers.json.fn.init.call(this,arg1);this.model=kendo.data.Model.define({init:function(data){var record;if(!data||jQuery.isEmptyObject(data)){data=transport._getInitialValues()}record=transport._convertDataTypes(data);transport.jsdo._deleteProdsProperties(record,true);kendo.data.Model.fn.init.call(this,record)},id:"_id",fields:transport._getModel()})},total:function(data){return data.total||(data.data?data.data.length:data.length)},data:function(data){return data.data||data}});JSDOTransport=kendo.data.RemoteTransport.extend({init:function(options){var transport=this,fnName;if(options.tableRef!==undefined){transport.tableRef=options.tableRef}transport.jsdo=initializeJSDO(transport,options);transport._initFromServer=false;transport.autoSave=options.autoSave!==undefined?options.autoSave:true;transport.readLocal=options.readLocal!==undefined?options.readLocal:false;transport.countFnName=options.countFnName;transport.useArrays=options.useArrays!==undefined?options.useArrays:false;if(transport.countFnName!==undefined){if(typeof transport.jsdo[transport.countFnName]!=="function"){throw new Error("Invoke operation '"+transport.countFnName+"' for countFnName is not defined.")}}else if(transport.jsdo._resource.generic.count!==undefined){for(fnName in transport.jsdo._resource.fn){if(transport.jsdo._resource.fn.hasOwnProperty(fnName)){if(transport.jsdo._resource.generic.count===transport.jsdo._resource.fn[fnName]["function"]){transport.countFnName=fnName;break}}}}JSDOObservable.one("info",function(e){e.sender._events.info.transport=transport});transport._initConvertTypes();kendo.data.RemoteTransport.fn.init.call(this,options)},_initConvertTypes:function(){var transport=this,i,schema,fieldName,dateFields=[],arrayFields=[],convertDateFields=false;transport._convertTypes=false;schema=transport.jsdo[transport.tableRef].getSchema();for(i=0;i0&&fieldName.charAt(0)!=="_"){if(schema[i].type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){dateFields.push(fieldName);if(!convertDateFields){convertDateFields=true}}else if(!transport.useArrays&&schema[i].type==="array"){arrayFields.push(fieldName);if(!convertDateFields&&schema[i].ablType&&schema[i].ablType.indexOf("DATE")===0){convertDateFields=true}}}}if(dateFields.length>0||arrayFields.length>0){transport._convertTypes=true;transport._convertFields={};transport._convertFields._arrayFields=[];transport._convertFields._dateFields=[]}if(dateFields.length>0){transport._convertFields._dateFields=dateFields}if(convertDateFields){transport._convertFields._datePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?$");transport._convertFields._dateTimePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?"+"T([0-9]{2})?:([0-9]{2})?:([0-9]{2})?.([0-9]{3})?$")}if(arrayFields.length>0){transport._convertFields._arrayFields=arrayFields}},_convertStringToDate:function(data,fieldName,targetFieldName){var transport=this,array,ablType,orig;if(!targetFieldName){targetFieldName=fieldName}array=transport._convertFields._datePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10))}else{ablType=transport.jsdo[transport.tableRef]._fields[fieldName.toLowerCase()].ablType;if(ablType==="DATETIME"){array=transport._convertFields._dateTimePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10),parseInt(array[4],10),parseInt(array[5],10),parseInt(array[6],10),parseInt(array[7],10))}}if(typeof data[targetFieldName]==="string"){orig=data[targetFieldName];try{data[targetFieldName]=new Date(data[targetFieldName])}catch(e){data[targetFieldName]=orig;console.log(progress.data._getMsgText("jsdoMSG000","_convertStringToDate() could not convert to date object: "+orig))}}}},_convertDataTypes:function(data){var transport=this,i,k,fieldName,schemaInfo,prefixElement,elementName,copy;if(!transport.useArrays&&transport._convertTypes&&transport._convertFields._arrayFields.length>0){copy={};transport.jsdo._copyRecord(transport.jsdo._buffers[transport.tableRef],data,copy);data=copy}if(!transport._convertTypes){return data}for(k=0;k0&&schema[i].name.charAt(0)!=="_"){type=schema[i].type;if(type==="integer"){type="number"}else if(type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){type="date"}if(type==="array"){for(j=0;j0&&schema[i].name.charAt(0)!=="_"){defaultValue=transport.jsdo._getDefaultValue(schema[i]);if(schema[i].type==="array"){data[schema[i].name]=[];for(j=0;j0||jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}else{this._initFromServer=jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}}data.data=[];if(this.readLocal&&this._initFromServer){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;data=this._getData(options);jsdo.useRelationships=saveUseRelationships;options.success(data);return}if(!this.readLocal){if(options.data){for(property in options.data){if(options.data.hasOwnProperty(property)){if(options.data[property]!==undefined&&optionsMapping[property]){if(filter===undefined){filter={}}filter[optionsMapping[property]]=options.data[property]}}}if(filter){filter.tableRef=this.tableRef}}}callback=function onAfterFillJSDO(object,success,request){var data={},saveUseRelationships,promise,total,exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;if(success){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;if(transport.readLocal){data=transport._getData(options)}else{data.data=jsdo[transport.tableRef].getData();total=jsdo.getProperty("server.count");if(total){data.total=total}}jsdo.useRelationships=saveUseRelationships;transport._initFromServer=true;if(options.data&&options.data.take){if(!transport.readLocal&&transport.countFnName!==undefined&&typeof jsdo[transport.countFnName]==="function"){if(options.data.skip===0&&options.data.take>data.data.length){options.success(data);return}promise=jsdo.invoke(transport.countFnName,{filter:request.objParam.filter});promise.then(function(object,success,request){var exception,total,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;try{if(typeof request.response==="object"&&Object.keys(request.response).length===1){total=request.response[Object.keys(request.response)];if(typeof total!=="number"){total=undefined}}}catch(e){}if(total!==undefined){if(total){data.total=total}options.success(data)}else{exception=new Error("Unexpected response from '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)}},function(object,success,request){var exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;exception=new Error("Error invoking '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)})}else{options.success(data)}}else{options.success(data)}}else{exception=new Error("Error while reading records.");options.error(request.xhr,request.xhr.status,exception)}};jsdo.fill(filter).then(callback,callback)}catch(e){options.error(null,null,e)}},_processChanges:function(options,request){var jsdo=this.jsdo,transport=this,array,i,jsrecord,id,record;if(options.batch){array=[];if(options.data.created instanceof Array){for(i=0;i=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}else if(this._resource.schema&&this._resource.schema.properties&&this._resource.schema.properties[tableName]&&this._resource.schema.properties[tableName].idProperty){this._resource.idProperty=this._resource.schema.properties[tableName].idProperty}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i'}else htmltext="";htmltext+='";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i'+'{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,defaultPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._pingtestOnReadyStateChange=function(){var xhr=this;if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}args.xhr=xhr};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,promise,authProviderInitObject={};function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){var jsdosession;try{jsdosession=new progress.data.JSDOSession(options);try{jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(e){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){loginHandler(authProvider)}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLoginResult(xhr,deferred)}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLogoutResult(xhr,deferred)}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){processRefreshResult(xhr,deferred)}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})();if(typeof kendo!=="undefined"){(function(){var JSDODataReader,JSDOTransport,JSDOObservable=new kendo.Observable;function initializeJSDO(transport,options){var jsdo,resourceName;if(options.jsdo instanceof progress.data.JSDO){jsdo=options.jsdo}else if(typeof options.jsdo==="string"){resourceName=options.jsdo;jsdo=new progress.data.JSDO({name:resourceName})}else{throw new Error("JSDO: jsdo property must be either a JSDO instance or a string.")}if(transport.tableRef===undefined&&jsdo._defaultTableRef){transport.tableRef=jsdo._defaultTableRef._name}if(transport.tableRef===undefined){throw new Error("JSDO: A tableRef must be specified when using a multi-table DataSet.")}else if(jsdo[transport.tableRef]===undefined){throw new Error("JSDO: tableRef '"+transport.tableRef+"' is not present in JSDO definition.")}return jsdo}JSDODataReader=kendo.data.readers.json.extend({init:function(arg1){var event={},transport;JSDOObservable.trigger("info",event);transport=this.transport=event.sender._events.info.transport;kendo.data.readers.json.fn.init.call(this,arg1);this.model=kendo.data.Model.define({init:function(data){var record;if(!data||jQuery.isEmptyObject(data)){data=transport._getInitialValues()}record=transport._convertDataTypes(data);transport.jsdo._deleteProdsProperties(record,true);kendo.data.Model.fn.init.call(this,record)},id:"_id",fields:transport._getModel()})},total:function(data){return data.total||(data.data?data.data.length:data.length)},data:function(data){return data.data||data}});JSDOTransport=kendo.data.RemoteTransport.extend({init:function(options){var transport=this,fnName;if(options.tableRef!==undefined){transport.tableRef=options.tableRef}transport.jsdo=initializeJSDO(transport,options);transport._initFromServer=false;transport.autoSave=options.autoSave!==undefined?options.autoSave:true;transport.readLocal=options.readLocal!==undefined?options.readLocal:false;transport.countFnName=options.countFnName;transport.useArrays=options.useArrays!==undefined?options.useArrays:false;if(transport.countFnName!==undefined){if(typeof transport.jsdo[transport.countFnName]!=="function"){throw new Error("Invoke operation '"+transport.countFnName+"' for countFnName is not defined.")}}else if(transport.jsdo._resource.generic.count!==undefined){for(fnName in transport.jsdo._resource.fn){if(transport.jsdo._resource.fn.hasOwnProperty(fnName)){if(transport.jsdo._resource.generic.count===transport.jsdo._resource.fn[fnName]["function"]){transport.countFnName=fnName;break}}}}JSDOObservable.one("info",function(e){e.sender._events.info.transport=transport});transport._initConvertTypes();kendo.data.RemoteTransport.fn.init.call(this,options)},_initConvertTypes:function(){var transport=this,i,schema,fieldName,dateFields=[],arrayFields=[],convertDateFields=false;transport._convertTypes=false;schema=transport.jsdo[transport.tableRef].getSchema();for(i=0;i0&&fieldName.charAt(0)!=="_"){if(schema[i].type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){dateFields.push(fieldName);if(!convertDateFields){convertDateFields=true}}else if(!transport.useArrays&&schema[i].type==="array"){arrayFields.push(fieldName);if(!convertDateFields&&schema[i].ablType&&schema[i].ablType.indexOf("DATE")===0){convertDateFields=true}}}}if(dateFields.length>0||arrayFields.length>0){transport._convertTypes=true;transport._convertFields={};transport._convertFields._arrayFields=[];transport._convertFields._dateFields=[]}if(dateFields.length>0){transport._convertFields._dateFields=dateFields}if(convertDateFields){transport._convertFields._datePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?$");transport._convertFields._dateTimePattern=new RegExp("^([0-9]+)?-([0-9]{2})?-([0-9]{2})?"+"T([0-9]{2})?:([0-9]{2})?:([0-9]{2})?.([0-9]{3})?$")}if(arrayFields.length>0){transport._convertFields._arrayFields=arrayFields}},_convertStringToDate:function(data,fieldName,targetFieldName){var transport=this,array,ablType,orig;if(!targetFieldName){targetFieldName=fieldName}array=transport._convertFields._datePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10))}else{ablType=transport.jsdo[transport.tableRef]._fields[fieldName.toLowerCase()].ablType;if(ablType==="DATETIME"){array=transport._convertFields._dateTimePattern.exec(data[targetFieldName])||[];if(array.length>0){data[targetFieldName]=new Date(parseInt(array[1],10),parseInt(array[2],10)-1,parseInt(array[3],10),parseInt(array[4],10),parseInt(array[5],10),parseInt(array[6],10),parseInt(array[7],10))}}if(typeof data[targetFieldName]==="string"){orig=data[targetFieldName];try{data[targetFieldName]=new Date(data[targetFieldName])}catch(e){data[targetFieldName]=orig;console.log(progress.data._getMsgText("jsdoMSG000","_convertStringToDate() could not convert to date object: "+orig))}}}},_convertDataTypes:function(data){var transport=this,i,k,fieldName,schemaInfo,prefixElement,elementName,copy;delete data["prods:rowState"];if(!transport.useArrays&&transport._convertTypes&&transport._convertFields._arrayFields.length>0){copy={};transport.jsdo._copyRecord(transport.jsdo._buffers[transport.tableRef],data,copy);data=copy}if(!transport._convertTypes){return data}for(k=0;k0&&schema[i].name.charAt(0)!=="_"){type=schema[i].type;if(type==="integer"){type="number"}else if(type==="string"&&schema[i].format&&schema[i].format.indexOf("date")!==-1){type="date"}if(type==="array"){for(j=0;j0&&schema[i].name.charAt(0)!=="_"){defaultValue=transport.jsdo._getDefaultValue(schema[i]);if(schema[i].type==="array"){data[schema[i].name]=[];for(j=0;j0||jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}else{this._initFromServer=jsdo[this.tableRef]._data instanceof Array&&jsdo[this.tableRef]._data.length>0}}data.data=[];if(this.readLocal&&this._initFromServer){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;data=this._getData(options);jsdo.useRelationships=saveUseRelationships;options.success(data);return}if(!this.readLocal){if(options.data){for(property in options.data){if(options.data.hasOwnProperty(property)){if(options.data[property]!==undefined&&optionsMapping[property]){if(filter===undefined){filter={}}filter[optionsMapping[property]]=options.data[property]}}}if(filter){filter.tableRef=this.tableRef}}}callback=function onAfterFillJSDO(object,success,request){var data={},saveUseRelationships,promise,total,exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;if(success){saveUseRelationships=jsdo.useRelationships;jsdo.useRelationships=false;if(transport.readLocal){data=transport._getData(options)}else{data.data=jsdo[transport.tableRef].getData();total=jsdo.getProperty("server.count");if(total){data.total=total}}jsdo.useRelationships=saveUseRelationships;transport._initFromServer=true;if(options.data&&options.data.take){if(!transport.readLocal&&transport.countFnName!==undefined&&typeof jsdo[transport.countFnName]==="function"){if(options.data.skip===0&&options.data.take>data.data.length){options.success(data);return}promise=jsdo.invoke(transport.countFnName,{filter:request.objParam.filter});promise.then(function(object,success,request){var exception,total,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;try{if(typeof request.response==="object"&&Object.keys(request.response).length===1){total=request.response[Object.keys(request.response)];if(typeof total!=="number"){total=undefined}}}catch(e){}if(total!==undefined){if(total){data.total=total}options.success(data)}else{exception=new Error("Unexpected response from '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)}},function(object,success,request){var exception,jsdo;object=progress.util.Deferred.getParamObject(object,success,request);jsdo=object.jsdo;success=object.success;request=object.request;exception=new Error("Error invoking '"+transport.countFnName+"' operation.");options.error(request.xhr,request.xhr.status,exception)})}else{options.success(data)}}else{options.success(data)}}else{exception=new Error("Error while reading records.");options.error(request.xhr,request.xhr.status,exception)}};jsdo.fill(filter).then(callback,callback)}catch(e){options.error(null,null,e)}},_processChanges:function(options,request){var jsdo=this.jsdo,transport=this,array,i,jsrecord,id,record;if(options.batch){array=[];if(options.data.created instanceof Array){if(jsdo._resource.idProperty){if(request.jsrecords){for(i=0;i=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i'}else htmltext="";htmltext+='";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i'+'{__format__}';progress.ui.UIHelper._defaultFieldTemplate='
'+''+'
';progress.ui.UIHelper._itemTemplate=progress.ui.UIHelper._defaultItemTemplate;progress.ui.UIHelper._fieldTemplate=progress.ui.UIHelper._defaultFieldTemplate;progress.ui.UIHelper.setItemTemplate=function(template){progress.ui.UIHelper._itemTemplate=template?template:progress.ui.UIHelper._defaultItemTemplate};progress.ui.UIHelper.setFieldTemplate=function(template){progress.ui.UIHelper._fieldTemplate=template?template:progress.ui.UIHelper._defaultFieldTemplate}})();(function(){if(progress===undefined){progress={}}if(progress.data===undefined){progress.data={}}progress.data.ServicesManager={};progress.data.ServicesManager._services=[];progress.data.ServicesManager._resources=[];progress.data.ServicesManager._data=[];progress.data.ServicesManager._sessions=[];progress.data.ServicesManager._jsdosessions=[];progress.data.ServicesManager.addResource=function(id,resource){if(progress.data.ServicesManager._resources[id]===undefined){progress.data.ServicesManager._resources[id]=resource}else{throw new Error("A resource named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getResource=function(id){return progress.data.ServicesManager._resources[id]};progress.data.ServicesManager.addService=function(id,service){if(progress.data.ServicesManager._services[id]===undefined){progress.data.ServicesManager._services[id]=service}else{throw new Error("A service named '"+id+"' was already loaded.")}};progress.data.ServicesManager.getService=function(id){return progress.data.ServicesManager._services[id]};progress.data.ServicesManager.addSession=function(catalogURI,session){if(progress.data.ServicesManager._sessions[catalogURI]===undefined){progress.data.ServicesManager._sessions[catalogURI]=session}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.addJSDOSession=function(catalogURI,jsdosession){if(progress.data.ServicesManager._jsdosessions[catalogURI]===undefined){progress.data.ServicesManager._jsdosessions[catalogURI]=jsdosession}else{throw new Error("Cannot load catalog '"+catalogURI+"' multiple times.")}};progress.data.ServicesManager.getSession=function(catalogURI){try{return progress.data.ServicesManager._sessions[catalogURI]}catch(e){return null}};progress.data.ServicesManager.cleanSession=function(session){var servicesKey,resourcesKey,sessionsKey,service,services=progress.data.ServicesManager._services,resources=progress.data.ServicesManager._resources,sessions=progress.data.ServicesManager._sessions,jsdosessions=progress.data.ServicesManager._jsdosessions;for(servicesKey in services){service=null;if(services[servicesKey]._session===session){service=services[servicesKey];delete services[servicesKey]}if(!service){continue}for(resourcesKey in resources){if(resources[resourcesKey].service===service){delete resources[resourcesKey]}}}for(sessionsKey in sessions){if(sessions[sessionsKey]===session){delete sessions[sessionsKey];if(jsdosessions[sessionsKey]){delete jsdosessions[sessionsKey]}}}};function extractParamsFromURL(url){var urlParams=[],paramName=null;if(typeof url==="string"){url.split("").forEach(function(c){if(c==="{"){paramName=""}else if(c==="}"){if(paramName){urlParams.push(paramName)}paramName=null}else if(paramName!==null){paramName+=c}})}return urlParams}progress.data.ServicesManager.addCatalog=function(services,session){var name,value;if(!services){throw new Error("Cannot find 'services' property in catalog file.")}if(services instanceof Array){services.forEach(function(service){if(progress.data.ServicesManager.getService(service.name)!==undefined){throw new Error("A service named '"+service.name+"' was already loaded.")}if(service.resources instanceof Array){service.resources.forEach(function(resource){if(progress.data.ServicesManager.getResource(resource.name)!==undefined){throw new Error("A resource named '"+resource.name+"' was already loaded.")}})}else{throw new Error("Missing 'resources' array in catalog.")}});for(var j=0;j1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","setContext",1))}if(typeof context==="object"){contextObject={};for(prop in context){if(context.hasOwnProperty(prop)){if(typeof context[prop]!=="function"){contextObject[prop]=context[prop]}}}}else if(context===undefined||context===null){contextObject={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","Session",1,"Object","setContextProperty"))}contextString=null};this.getContext=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContext",0))}return contextObject};this.getContextProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","Session","getContextProperty",1))}return contextObject[propertyName]}};progress.data.Session=function Session(options){var defPropSupported=false;if(typeof Object.defineProperty==="function"){defPropSupported=true}var that=this,jsdosession,isUserAgentiOS=false,isFirefox=false,isEdge=false,isIE=false,canPassCredentialsToOpenWithCORS=false,defaultiOSBasicAuthTimeout=4e3,deviceIsOnline=true,restApplicationIsOnline=false,oepingAvailable=false,defaultPartialPingURI="/rest/_oeping",partialPingURI=defaultPartialPingURI,_storageKey,_authProvider=null,customCredentials=false,storedAuthModel,storedURI,newURI,stateWasReadFromStorage=false;if(!options||options._silent!==true){console.warn("Session: As of JSDO 4.4, the Session object has been deprecated. "+"Please use the JSDOSession object instead.")}if(typeof navigator!=="undefined"){if(typeof navigator.userAgent!=="undefined"){isUserAgentiOS=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;isEdge=navigator.userAgent.indexOf("Edge/")>-1;isIE=navigator.userAgent.indexOf("Trident/")>-1||navigator.userAgent.indexOf("MSIE 10")>-1}}canPassCredentialsToOpenWithCORS=!(isFirefox||isEdge||isIE);function canPassCredentialsToOpen(){return canPassCredentialsToOpenWithCORS}this._onlineHandler=function(){setDeviceIsOnline(true);that.trigger("online",that,null)};this._offlineHandler=function(){setDeviceIsOnline(false);that.trigger("offline",that,progress.data.Session.DEVICE_OFFLINE,null)};if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("online",this._onlineHandler,false);window.addEventListener("offline",this._offlineHandler,false)}var _catalogURIs=[];var _services=[];var _jsdos=[];this.onOpenRequest=null;var _password=null;if(defPropSupported){var _userName=null;Object.defineProperty(this,"userName",{get:function(){return _userName},enumerable:true});var _loginTarget="/static/home.html";Object.defineProperty(this,"loginTarget",{get:function(){return _loginTarget},enumerable:true});var _serviceURI=null;Object.defineProperty(this,"serviceURI",{get:function(){return _serviceURI},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _catalogURIs},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _services},enumerable:true});var _loginResult=null;Object.defineProperty(this,"loginResult",{get:function(){return _loginResult},enumerable:true});var _loginHttpStatus=null;Object.defineProperty(this,"loginHttpStatus",{get:function(){return _loginHttpStatus},enumerable:true});var _clientContextId=null;Object.defineProperty(this,"clientContextId",{get:function(){return _clientContextId},enumerable:true});var _authenticationModel=progress.data.Session.AUTH_TYPE_ANON;Object.defineProperty(this,"authenticationModel",{get:function(){return _authenticationModel},set:function(newval){if(newval){newval=newval.toLowerCase()}switch(newval){case progress.data.Session.AUTH_TYPE_FORM:case progress.data.Session.AUTH_TYPE_BASIC:case progress.data.Session.AUTH_TYPE_ANON:case progress.data.Session.AUTH_TYPE_SSO:case null:_authenticationModel=newval;storeSessionInfo("authenticationModel",newval);break;default:throw new Error("Error setting Session.authenticationModel. '"+newval+"' is an invalid value.")}},enumerable:true});var _lastSessionXHR=null;Object.defineProperty(this,"lastSessionXHR",{get:function(){return _lastSessionXHR},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return this.loginResult===progress.data.Session.LOGIN_SUCCESS&&restApplicationIsOnline&&deviceIsOnline},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _jsdos},enumerable:true});var _pingInterval=0;var _timeoutID=null;Object.defineProperty(this,"pingInterval",{get:function(){return _pingInterval},set:function(newval){if(typeof newval==="number"&&newval>=0){_pingInterval=newval;storeSessionInfo("pingInterval",newval);if(newval>0){if(this.loginResult===progress.data.Session.LOGIN_SUCCESS){_timeoutID=setTimeout(this._autoping,newval)}}else if(newval===0){clearTimeout(_timeoutID);_pingInterval=0}}else{throw new Error("Error setting Session.pingInterval. '"+newval+"' is an invalid value.")}},enumerable:true});var _contextProperties=new progress.data.ContextProperties;Object.defineProperty(this,"_contextProperties",{get:function(){return _contextProperties},enumerable:false});var isInvalidated=false;Object.defineProperty(this,"_isInvalidated",{get:function(){return isInvalidated},enumerable:false});Object.defineProperty(this,"_authProvider",{get:function(){return _authProvider},set:function(newval){if(_authProvider){throw new Error("Internal Error setting Session._authProvider. '"+"The property has already been set.")}setAuthProvider(newval)},enumerable:false})}else{this.userName=null;this.loginTarget="/static/home.html";this.serviceURI=null;this.catalogURIs=[];this.services=[];this.loginResult=null;this.loginHttpStatus=null;this.clientContextId=null;this.authenticationModel=progress.data.Session.AUTH_TYPE_ANON;this.lastSessionXHR=null}function storeSessionInfo(infoName,value){var key;if(that.loginResult===progress.data.Session.LOGIN_SUCCESS&&typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}if(typeof value!=="undefined"){sessionStorage.setItem(key,JSON.stringify(value))}}}function retrieveSessionInfo(infoName){var key,jsonStr,value=null;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName}jsonStr=sessionStorage.getItem(key);if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}}function clearSessionInfo(infoName){var key;if(typeof sessionStorage==="object"&&_storageKey){key=_storageKey;if(infoName){key=key+"."+infoName;sessionStorage.removeItem(key)}}}function storeAllSessionInfo(){if(_storageKey){storeSessionInfo("loginResult",that.loginResult);storeSessionInfo("userName",that.userName);storeSessionInfo("serviceURI",that.serviceURI);storeSessionInfo("loginHttpStatus",that.loginHttpStatus);storeSessionInfo("authenticationModel",that.authenticationModel);storeSessionInfo("pingInterval",that.pingInterval);storeSessionInfo("oepingAvailable",oepingAvailable);storeSessionInfo("partialPingURI",partialPingURI);storeSessionInfo("clientContextId",that.clientContextId);storeSessionInfo("deviceIsOnline",deviceIsOnline);storeSessionInfo("restApplicationIsOnline",restApplicationIsOnline);if(that._authProvider){storeSessionInfo("_authProvider.init",{uri:that._authProvider.uri,authenticationModel:that._authProvider.authenticationModel})}storeSessionInfo(_storageKey,true)}}function clearAllSessionInfo(){if(_storageKey){if(retrieveSessionInfo(_storageKey)){clearSessionInfo("loginResult");clearSessionInfo("userName");clearSessionInfo("serviceURI");clearSessionInfo("loginHttpStatus");clearSessionInfo("clientContextId");clearSessionInfo("deviceIsOnline");clearSessionInfo("restApplicationIsOnline");clearSessionInfo("authenticationModel");clearSessionInfo("pingInterval");clearSessionInfo("oepingAvailable");clearSessionInfo("partialPingURI");clearSessionInfo("_authProvider.init");clearSessionInfo(_storageKey)}}}function setSessionInfoFromStorage(key){var authproviderInitObject;if(retrieveSessionInfo(key)){setLoginResult(retrieveSessionInfo("loginResult"),this);setUserName(retrieveSessionInfo("userName"),this);setServiceURI(retrieveSessionInfo("serviceURI"),this);setLoginHttpStatus(retrieveSessionInfo("loginHttpStatus"),this);setClientContextID(retrieveSessionInfo("clientContextId"),this);setDeviceIsOnline(retrieveSessionInfo("deviceIsOnline"));setRestApplicationIsOnline(retrieveSessionInfo("restApplicationIsOnline"));that.authenticationModel=retrieveSessionInfo("authenticationModel");that.pingInterval=retrieveSessionInfo("pingInterval");setOepingAvailable(retrieveSessionInfo("oepingAvailable"));setPartialPingURI(retrieveSessionInfo("partialPingURI"));if(!that._authProvider){authproviderInitObject=retrieveSessionInfo("_authProvider.init");if(authproviderInitObject){setAuthProvider(new progress.data.AuthenticationProvider(authproviderInitObject))}}}}function setUserName(newname,sessionObject){if(defPropSupported){_userName=newname}else{sessionObject.userName=newname}storeSessionInfo("userName",newname)}function setLoginTarget(target,sessionObject){if(defPropSupported){_loginTarget=target}else{sessionObject.loginTarget=target}}function setServiceURI(url,sessionObject){if(defPropSupported){_serviceURI=url}else{sessionObject.serviceURI=url}storeSessionInfo("serviceURI",url)}function pushCatalogURIs(url,sessionObject){if(defPropSupported){_catalogURIs.push(url)}else{sessionObject.catalogURIs.push(url)}}function pushService(serviceObject,sessionObject){if(defPropSupported){_services.push(serviceObject)}else{sessionObject.services.push(serviceObject)}}function findService(serviceName){_services.forEach(function(service){if(service.name===serviceName){return service}});return null}function setLoginResult(result,sessionObject){if(defPropSupported){_loginResult=result}else{sessionObject.loginResult=result}if(result===progress.data.Session.LOGIN_SUCCESS){storeSessionInfo("loginResult",result)}else{clearAllSessionInfo()}}function setLoginHttpStatus(status,sessionObject){if(defPropSupported){_loginHttpStatus=status}else{sessionObject.loginHttpStatus=status}storeSessionInfo("loginHttpStatus",status)}function setClientContextIDfromXHR(xhr,sessionObject){if(xhr){setClientContextID(getResponseHeaderNoError(xhr,"X-CLIENT-CONTEXT-ID"),sessionObject)}}function setClientContextID(ccid,sessionObject){if(defPropSupported){_clientContextId=ccid}else{sessionObject.clientContextId=ccid}storeSessionInfo("clientContextId",ccid)}function setLastSessionXHR(xhr,sessionObject){if(defPropSupported){_lastSessionXHR=xhr}else{sessionObject.lastSessionXHR=xhr}}function setDeviceIsOnline(value){deviceIsOnline=value;storeSessionInfo("deviceIsOnline",value)}function setAuthProvider(value){_authProvider=value?value:null}function setRestApplicationIsOnline(value){restApplicationIsOnline=value;storeSessionInfo("restApplicationIsOnline",value)}function setOepingAvailable(value){oepingAvailable=value;storeSessionInfo("oepingAvailable",value)}function setPartialPingURI(value){partialPingURI=value;storeSessionInfo("partialPingURI",value)}function getResponseHeaderNoError(xhr,headerName){var allHeaders=xhr._pdsResponseHeaders,regExp;if(allHeaders===undefined){allHeaders=xhr.getAllResponseHeaders();if(allHeaders){xhr._pdsResponseHeaders=allHeaders}else{xhr._pdsResponseHeaders=null}}if(allHeaders){regExp=new RegExp("^"+headerName+":","mi");if(allHeaders.match(regExp)){return xhr.getResponseHeader(headerName)}}return null}this._pushJSDOs=function(jsdo){_jsdos.push(jsdo)};this._openRequest=function(xhr,verb,url,async,callback){var urlPlusCCID,that=this;function afterOpenAndAuthorize(arg){if(arg instanceof Error){throw arg}else{if(that.clientContextId&&that.clientContextId!=="0"){xhr.setRequestHeader("X-CLIENT-CONTEXT-ID",that.clientContextId)}setRequestHeaderFromContextProps(that,xhr);if(typeof that.onOpenRequest==="function"){var params={xhr:xhr,verb:verb,uri:urlPlusCCID,async:async,formPreTest:false,session:that};that.onOpenRequest(params)}if(callback){callback()}}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to make server request when there is no active session.")}urlPlusCCID=this._prependAppURL(url);urlPlusCCID=this._addCCIDtoURL(urlPlusCCID);if(progress.data.Session._useTimeStamp){urlPlusCCID=progress.data.Session._addTimeStampToURL(urlPlusCCID)}if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,verb,urlPlusCCID,async,afterOpenAndAuthorize)}else{this._setXHRCredentials(xhr,verb,urlPlusCCID,this.userName,_password,async);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json")}afterOpenAndAuthorize(xhr)}};this.pingTestCallback=function(cbArgs){var foundOeping=cbArgs.pingResult?true:false;setOepingAvailable(foundOeping)};this._onReadyStateChangeGeneric=function(){var xhr=this;var result;var errorObject;clearTimeout(xhr._requestTimeout);if(xhr.readyState===4){result=null;errorObject=null;if(typeof xhr.onResponseFn==="function"){try{result=xhr.onResponseFn(xhr)}catch(e){errorObject=e}}if(typeof xhr.onResponseProcessedFn==="function"){if(!result){result=progress.data.Session.GENERAL_FAILURE}xhr.onResponseProcessedFn(xhr.pdsession,result,errorObject,xhr)}}};this._disconnect=function(deferred){this._processDisconnectResult(null,deferred)};this._processDisconnectResult=function(xhr,deferred){this._reinitializeAfterLogout(this,progress.data.Session.SUCCESS);this._disconnectComplete(this,progress.data.Session.SUCCESS,null,null,deferred)};this._disconnectComplete=function(pdsession,result,errObj,xhr,deferred){pdsession.trigger("afterDisconnect",pdsession,result,errObj,xhr,deferred)};var pwSave=null;var unameSave=null;this.login=function(serviceURI,loginUserName,loginPassword,loginTarget){var uname,pw,isAsync=false,args=[],deferred,iOSBasicAuthTimeout,uriForRequest;pwSave=null;unameSave=null;if(!defPropSupported){this.authenticationModel=this.authenticationModel.toLowerCase()}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","login()"))}if(this.loginResult===progress.data.Session.LOGIN_SUCCESS||this._authProvider){throw new Error("Attempted to call login() on a Session object that is already logged in.")}if(arguments.length>0){if(arguments[0]&&typeof arguments[0]==="object"){args[0]=arguments[0].serviceURI;args[1]=arguments[0].userName;args[2]=arguments[0].password;args[3]=arguments[0].loginTarget;args[4]=arguments[0].async;deferred=arguments[0].deferred;iOSBasicAuthTimeout=arguments[0].iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","login","The iOSBasicAuthTimeout argument was invalid."))}}else{args=arguments}}if(args.length>0){if(args[0]){var restURLtemp=args[0];if(restURLtemp[restURLtemp.length-1]==="/"){restURLtemp=restURLtemp.substring(0,restURLtemp.length-1)}setServiceURI(restURLtemp,this)}else if(!this.serviceURI){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}if(args[1]){uname=args[1]}if(args[2]){pw=args[2]}if(args[3]){setLoginTarget(args[3],this)}if(args[4]){if(typeof args[4]==="boolean"){isAsync=args[4]}else{throw new Error("Session.login() was passed an async setting that is not a boolean.")}}}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);throw new Error("Session.login() is missing the serviceURI argument.")}unameSave=uname;pwSave=pw;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON||this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){uname=null;pw=null}var xhr=new XMLHttpRequest;xhr.pdsession=this;try{uriForRequest=this.serviceURI+this.loginTarget;if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(uriForRequest)}this._setXHRCredentials(xhr,"GET",uriForRequest,uname,pw,isAsync);progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(this,xhr);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr._isAsync=isAsync;if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){xhr.onResponseFn=this._afterFormPretestLogin}else{xhr.onResponseFn=this._processLoginResult;xhr.onResponseProcessedFn=this._loginComplete}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout>0){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred}if(typeof this.onOpenRequest==="function"){var isFormPreTest=false;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){isFormPreTest=true}setLastSessionXHR(xhr,this);var params={xhr:xhr,verb:"GET",uri:this.serviceURI+this.loginTarget,async:false,formPreTest:isFormPreTest,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send(null)}catch(e){clearTimeout(xhr._requestTimeout);setLoginHttpStatus(xhr.status,this);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,this);unameSave=null;pwSave=null;throw e}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{setLoginHttpStatus(xhr.status,this);if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){return this._afterFormPretestLogin(xhr)}else{return this._processLoginResult(xhr)}}};this._afterFormPretestLogin=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);var formLoginParams={xhr:xhr,pw:pwSave,uname:unameSave,theSession:pdsession};try{return doFormLogin(formLoginParams)}catch(e){pwSave=null;unameSave=null;throw e}};function doFormLogin(args){var xhr=args.xhr;var theSession=args.theSession;var oldXHR;var contentType=null;var needAuth=false;var params={session:theSession,xhr:xhr,statusFromjson:null};contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson||params.statusFromjson>=400&¶ms.statusFromjson<500){needAuth=true}else{setLoginHttpStatus(params.statusFromjson,theSession)}}else{if(theSession.loginHttpStatus===200){if(_gotLoginForm(xhr)){needAuth=true}}}if(needAuth){oldXHR=xhr;xhr=new XMLHttpRequest;args.xhr=xhr;params.xhr=xhr;xhr.pdsession=oldXHR.pdsession;xhr._isAsync=oldXHR._isAsync;xhr._deferred=oldXHR._deferred;xhr._jsdosession=oldXHR._jsdosession;xhr.open("POST",theSession.serviceURI+"/static/auth/j_spring_security_check",xhr._isAsync);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.setRequestHeader("Cache-Control","max-age=0");setRequestHeaderFromContextProps(theSession,xhr);_addWithCredentialsAndAccept(xhr,"application/json");try{if(typeof theSession.onOpenRequest==="function"){var cbparams={xhr:xhr,verb:"POST",uri:theSession.serviceURI+"/static/auth/j_spring_security_check",async:xhr._isAsync,formPreTest:false,session:theSession};theSession.onOpenRequest(cbparams);xhr=cbparams.xhr}if(xhr._isAsync){xhr.onreadystatechange=theSession._onReadyStateChangeGeneric;xhr.onResponseFn=theSession._afterFormLogin;xhr.onResponseProcessedFn=theSession._loginComplete}xhr.send("j_username="+encodeURIComponent(args.uname)+"&j_password="+encodeURIComponent(args.pw)+"&submit=Submit")}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,theSession);setLoginHttpStatus(xhr.status,theSession);unameSave=null;pwSave=null;throw e}}if(xhr._isAsync&&!needAuth){xhr.onResponseProcessedFn=theSession._loginComplete;return theSession._afterFormLogin(xhr)}if(!xhr._isAsync){return theSession._afterFormLogin(xhr)}}this._afterFormLogin=function(xhr){var theSession=xhr.pdsession;var params={session:theSession,xhr:xhr,statusFromjson:null};var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>=0){handleJSONLoginResponse(params);if(!params.statusFromjson){throw new Error("Internal OpenEdge Mobile client error handling login response. HTTP status: "+xhr.status+".")}setLoginHttpStatus(params.statusFromjson,theSession)}else{if(xhr.status===200){if(_gotLoginFailure(xhr)||_gotLoginForm(xhr)){setLoginHttpStatus(401,theSession)}else{setLoginHttpStatus(xhr.status,theSession)}}}return theSession._processLoginResult(xhr)};this._processLoginResult=function(xhr){var pdsession=xhr.pdsession;setLoginHttpStatus(xhr.status,xhr.pdsession);if(pdsession.loginHttpStatus===200){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);setUserName(unameSave,pdsession);_password=pwSave;pdsession._saveClientContextId(xhr);storeAllSessionInfo();var pingTestArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:pdsession._pingtestOnReadyStateChange};pingTestArgs.pingURI=pdsession._makePingURI();pdsession._sendPing(pingTestArgs)}else{if(pdsession.loginHttpStatus===401){setLoginResult(progress.data.Session.LOGIN_AUTHENTICATION_FAILURE,pdsession)}else{setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);unameSave=null;pwSave=null;if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","login"))}return pdsession.loginResult};this._loginComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterLogin",pdsession,result,errObj,xhr)};this.logout=function(args){var isAsync=false,errorObject=null,xhr,deferred,params;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","Session","logout()"))}if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&this.authenticationModel){throw new Error("Attempted to call logout when there is no active session.")}if(typeof args==="object"){isAsync=args.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","logout","The async argument was invalid."))}deferred=args.deferred}xhr=new XMLHttpRequest;xhr.pdsession=this;try{xhr._jsdosession=jsdosession;xhr._deferred=deferred;if(this.authenticationModel===progress.data.Session.AUTH_TYPE_FORM||this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(isAsync){xhr.onreadystatechange=this._onReadyStateChangeGeneric;xhr.onResponseFn=this._processLogoutResult;xhr.onResponseProcessedFn=this._logoutComplete}xhr.open("GET",this.serviceURI+"/static/auth/j_spring_security_logout",isAsync);try{xhr.withCredentials=true}catch(e){}xhr.setRequestHeader("Accept","application/json");setRequestHeaderFromContextProps(this,xhr);if(typeof this.onOpenRequest==="function"){setLastSessionXHR(xhr,this);params={xhr:xhr,verb:"GET",uri:this.serviceURI+"/static/auth/j_spring_security_logout",async:false,formPreTest:false,session:this};this.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,this);xhr.send()}else{xhr._anonymousLogoutOK=true}}catch(e){this._reinitializeAfterLogout(this,false);throw e}if(!isAsync){try{this._processLogoutResult(xhr)}catch(e){throw e}}if(isAsync&&this.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){try{this._processLogoutResult(xhr)}catch(e){errorObject=e}this._logoutComplete(this,null,errorObject,xhr)}};this.invalidate=function(){isInvalidated=true;cleanServicesManager()};this._logoutComplete=function(pdsession,result,errorObject,xhr){pdsession.trigger("afterLogout",pdsession,errorObject,xhr)};this._processLogoutResult=function(xhr){var logoutSucceeded;var pdsession=xhr.pdsession;var basicStatusOK=false;if(xhr._anonymousLogoutOK){logoutSucceeded=true}else if(xhr.status!==200){if(pdsession.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(xhr.status===404){logoutSucceeded=true}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=false;throw new Error("Error logging out, HTTP status = "+xhr.status)}}else{logoutSucceeded=true}updateContextPropsFromResponse(pdsession,xhr);pdsession._reinitializeAfterLogout(pdsession,logoutSucceeded)};this._reinitializeAfterLogout=function(pdsession,success){setLoginResult(null,pdsession);setLoginHttpStatus(null,pdsession);setClientContextID(null,pdsession);setUserName(null,pdsession);setAuthProvider(null);_password=null;if(success){setRestApplicationIsOnline(false);setOepingAvailable(false);setPartialPingURI(defaultPartialPingURI);setLastSessionXHR(null,pdsession);clearTimeout(_timeoutID)}};this.addCatalog=function(arg1,arg2,arg3,arg4){var catalogURI,catalogUserName,catalogPassword,isAsync=false,xhr,deferred,iOSBasicAuthTimeout,catalogIndex,authProvider,that=this;function addCatalogAfterOpen(){progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(isAsync){xhr.onreadystatechange=that._onReadyStateChangeGeneric;xhr.onResponseFn=that._processAddCatalogResult;xhr.onResponseProcessedFn=that._addCatalogComplete;if(that.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC&&isUserAgentiOS&&iOSBasicAuthTimeout){xhr._requestTimeout=setTimeout(function(){clearTimeout(xhr._requestTimeout);xhr._iosTimeOutExpired=true;xhr.abort()},iOSBasicAuthTimeout)}xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex}try{if(typeof that.onOpenRequest==="function"){setLastSessionXHR(xhr,that);var params={xhr:xhr,verb:"GET",uri:catalogURI,async:false,formPreTest:false,session:that};that.onOpenRequest(params);xhr=params.xhr}setLastSessionXHR(xhr,that);xhr.send(null)}catch(e){throw new Error("Error retrieving catalog '"+catalogURI+"'.\n"+e.message)}if(isAsync){return progress.data.Session.ASYNC_PENDING}else{return that._processAddCatalogResult(xhr)}}if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}customCredentials=true;if(arguments.length>0){if(typeof arg1==="object"){if(!arguments[0].offlineAddCatalog){if(this.loginResult!==progress.data.Session.LOGIN_SUCCESS&&!this._authProvider&&this.authenticationModel){throw new Error("Attempted to call addCatalog when there is no active session.")}}catalogURI=arg1.catalogURI;if(!catalogURI||typeof catalogURI!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogURI argument was missing or invalid."))}catalogUserName=arg1.userName;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogUserName argument was invalid."))}catalogPassword=arg1.password;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The catalogPassword argument was invalid."))}isAsync=arg1.async;if(isAsync&&typeof isAsync!=="boolean"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The async argument was invalid."))}iOSBasicAuthTimeout=arg1.iOSBasicAuthTimeout;if(typeof iOSBasicAuthTimeout==="undefined"){iOSBasicAuthTimeout=defaultiOSBasicAuthTimeout}else if(iOSBasicAuthTimeout&&typeof iOSBasicAuthTimeout!=="number"){throw new Error(progress.data._getMsgText("jsdoMSG033","Session","addCatalog","The iOSBasicAuthTimeout argument was invalid."))}authProvider=arg1.authProvider;deferred=arg1.deferred;catalogIndex=arg1.catalogIndex}else{catalogURI=arg1;if(typeof catalogURI!=="string"){throw new Error("First argument to Session.addCatalog must be the URL of the catalog.")}catalogUserName=arg2;if(catalogUserName&&typeof catalogUserName!=="string"){throw new Error("Second argument to Session.addCatalog must be a user name string.")}catalogPassword=arg3;if(catalogPassword&&typeof catalogPassword!=="string"){throw new Error("Third argument to Session.addCatalog must be a password string.")}}}else{throw new Error("Session.addCatalog is missing its first argument, the URL of the catalog.")}if(!authProvider){authProvider=this._authProvider;customCredentials=false}if(!catalogUserName){catalogUserName=this.userName}if(!catalogPassword){catalogPassword=_password}xhr=new XMLHttpRequest;xhr.pdsession=this;xhr._catalogURI=catalogURI;if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){if(isAsync){xhr._jsdosession=jsdosession;xhr._deferred=deferred;xhr._catalogIndex=catalogIndex;setTimeout(this._addCatalogComplete,10,this,progress.data.Session.CATALOG_ALREADY_LOADED,null,xhr);return progress.data.Session.ASYNC_PENDING}return progress.data.Session.CATALOG_ALREADY_LOADED}if(authProvider){authProvider._openRequestAndAuthorize(xhr,"GET",catalogURI,isAsync,addCatalogAfterOpen);return progress.data.Session.ASYNC_PENDING}else{this._setXHRCredentials(xhr,"GET",catalogURI,catalogUserName,catalogPassword,isAsync);return addCatalogAfterOpen()}};this._processAddCatalogResult=function(xhr){var _catalogHttpStatus=xhr.status;var theSession=xhr.pdsession;var servicedata;var catalogURI=xhr._catalogURI,serviceURL,theJSDOSession=jsdosession;if(!customCredentials){toggleOnlineState(xhr)}if((_catalogHttpStatus===200||_catalogHttpStatus===0)&&xhr.responseText){servicedata=theSession._parseCatalog(xhr);try{progress.data.ServicesManager.addCatalog(servicedata,theSession)}catch(e){if(progress.data.ServicesManager.getSession(catalogURI)!==undefined){return progress.data.Session.CATALOG_ALREADY_LOADED}throw new Error("Error processing catalog '"+catalogURI+"'. \n"+e.message)}servicedata.forEach(function(service){serviceURL=theSession._prependAppURL(service.address);pushService(new progress.data.MobileServiceObject({name:service.name,uri:serviceURL}),theSession);if(service.settings&&service.settings.useXClientProps&&!theSession.xClientProps){console.warn("Catalog warning: Service settings property 'useXClientProps' "+"is true but 'xClientProps' property has not been set.")}});pushCatalogURIs(catalogURI,theSession);progress.data.ServicesManager.addSession(catalogURI,theSession);if(theJSDOSession){progress.data.ServicesManager.addJSDOSession(catalogURI,theJSDOSession)}}else if(_catalogHttpStatus===401){return progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else if(xhr._iosTimeOutExpired){throw new Error(progress.data._getMsgText("jsdoMSG047","addCatalog"))}else{throw new Error("Error retrieving catalog '"+catalogURI+"'. Http status: "+_catalogHttpStatus+".")}return progress.data.Session.SUCCESS};this._addCatalogComplete=function(pdsession,result,errObj,xhr){pdsession.trigger("afterAddCatalog",pdsession,result,errObj,xhr)};this.ping=function(args){var pingResult=false,pingArgs={pingURI:null,async:true,onCompleteFn:null,fireEventIfOfflineChange:true,onReadyStateFn:this._onReadyStateChangePing,offlineReason:null};if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","Session"))}if(!this._authProvider&&this.loginResult!==progress.data.Session.LOGIN_SUCCESS){throw new Error("Attempted to call ping when not logged in.")}if(args){if(args.async!==undefined){pingArgs.async=args.async}if(args.doNotFireEvent!==undefined){pingArgs.fireEventIfOfflineChange=!args.doNotFireEvent}if(args.onCompleteFn&&typeof args.onCompleteFn==="function"){pingArgs.onCompleteFn=args.onCompleteFn}pingArgs.deferred=args.deferred;pingArgs.jsdosession=args.jsdosession}pingArgs.pingURI=that._makePingURI();that._sendPing(pingArgs);if(!pingArgs.async){if(pingArgs.xhr){pingResult=that._processPingResult(pingArgs);if(args.offlineReason!==undefined){args.offlineReason=pingArgs.offlineReason}}else{pingResult=false}if(args.xhr!==undefined){args.xhr=pingArgs.xhr}}return pingResult};this._isOnlineStateChange=function(isOnline){var stateChanged=false;if(isOnline&&!this.connected){stateChanged=true}else if(!isOnline&&this.connected){stateChanged=true}return stateChanged};this._checkServiceResponse=function(xhr,success,request){var offlineReason=null,wasOnline=this.connected;updateContextPropsFromResponse(this,xhr);if(!this._events){return}var offlineObservers=this._events.offline||[];var onlineObservers=this._events.online||[];if(offlineObservers.length===0&&onlineObservers.length===0){return}if(success){setRestApplicationIsOnline(true);setDeviceIsOnline(true)}else{if(deviceIsOnline){var localPingArgs={doNotFireEvent:true,offlineReason:null,async:false};if(!that.ping(localPingArgs)){offlineReason=localPingArgs.offlineReason;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}}if(wasOnline&&!this.connected){this.trigger("offline",this,offlineReason,request)}else if(!wasOnline&&this.connected){this.trigger("online",this,request)}};this._processPingResult=function(args){var xhr=args.xhr,pingResponseJSON,appServerStatus=null,wasOnline=this.connected,connectedBeforeCallback,assumeOepingFormat;if(args.hasOwnProperty("usingOepingFormat")){assumeOepingFormat=args.usingOepingFormat}else{assumeOepingFormat=oepingAvailable}if(xhr.status>=200&&xhr.status<300){updateContextPropsFromResponse(this,xhr);if(assumeOepingFormat){try{pingResponseJSON=JSON.parse(xhr.responseText);appServerStatus=pingResponseJSON.AppServerStatus}catch(e){console.error("Unable to parse ping response.")}}toggleOnlineState(xhr)}else{if(deviceIsOnline){if(xhr.status===0){args.offlineReason=progress.data.Session.SERVER_OFFLINE;setRestApplicationIsOnline(false)}else if(xhr.status===404||xhr.status===410){args.offlineReason=progress.data.Session.WEB_APPLICATION_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}else{args.offlineReason=progress.data.Session.DEVICE_OFFLINE}}if(appServerStatus){if(appServerStatus.PingStatus==="false"){args.offlineReason=progress.data.Session.APPSERVER_OFFLINE;setRestApplicationIsOnline(false)}else{setRestApplicationIsOnline(true)}}connectedBeforeCallback=this.connected;if(typeof xhr.onCompleteFn==="function"){xhr.onCompleteFn({pingResult:this.connected,xhr:xhr,offlineReason:args.offlineReason})}if(args.fireEventIfOfflineChange){if(wasOnline&&!connectedBeforeCallback){that.trigger("offline",that,args.offlineReason,null)}else if(!wasOnline&&connectedBeforeCallback){that.trigger("online",that,null)}}return this.connected};this._onReadyStateChangePing=function(){var xhr=this;var args;if(xhr.readyState===4){args={xhr:xhr,fireEventIfOfflineChange:true,offlineReason:null};that._processPingResult(args);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._pingtestOnReadyStateChange=function(){var xhr=this;if(xhr.readyState===4){var foundOeping=false;if(xhr.status>=200&&xhr.status<300){foundOeping=true}else{setPartialPingURI(that.loginTarget);console.warn("Default ping target not available, will use loginTarget instead.")}setOepingAvailable(foundOeping);if(_pingInterval>0){_timeoutID=setTimeout(that._autoping,_pingInterval)}}};this._sendPing=function(args){var xhr=new XMLHttpRequest,that=this;function sendPingAfterOpen(){if(args.async){xhr.onreadystatechange=args.onReadyStateFn;xhr.onCompleteFn=args.onCompleteFn;xhr._jsdosession=jsdosession;xhr._deferred=args.deferred}progress.data.Session._setNoCacheHeaders(xhr);setRequestHeaderFromContextProps(that,xhr);if(that.authenticationModel===progress.data.Session.AUTH_TYPE_FORM){_addWithCredentialsAndAccept(xhr,"application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")}xhr.send(null)}try{if(this._authProvider){this._authProvider._openRequestAndAuthorize(xhr,"GET",args.pingURI,args.async,sendPingAfterOpen)}else{this._setXHRCredentials(xhr,"GET",args.pingURI,this.userName,_password,args.async);if(xhr.readyState===1){sendPingAfterOpen()}}}catch(e){args.error=e}args.xhr=xhr};this._makePingURI=function(){var pingURI=this.serviceURI+partialPingURI;if(progress.data.Session._useTimeStamp){pingURI=progress.data.Session._addTimeStampToURL(pingURI)}return pingURI};this._autoping=function(){that.ping({async:true})};this._setXHRCredentials=function(xhr,verb,uri,userName,password,async){if(userName&&this.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){if(canPassCredentialsToOpen()){xhr.open(verb,uri,async,userName,password)}else{xhr.open(verb,uri,async)}var auth=_make_basic_auth(userName,password);xhr.setRequestHeader("Authorization",auth)}else{xhr.open(verb,uri,async)}};this._addCCIDtoURL=function(url){var urlPart1,urlPart2,jsessionidStr,index;if(this.clientContextId&&this.clientContextId!=="0"){if(url.substring(0,this.serviceURI.length)===this.serviceURI){jsessionidStr=";"+"JSESSIONID="+this.clientContextId;index=url.indexOf("?");if(index===-1){url+=jsessionidStr}else{urlPart1=url.substring(0,index);urlPart2=url.substring(index);url=urlPart1+jsessionidStr+urlPart2}}}return url};this._saveClientContextId=function(xhr){setClientContextIDfromXHR(xhr,this)};this._parseCatalog=function(xhr){var jsonObject;var catalogdata;try{jsonObject=JSON.parse(xhr.responseText);catalogdata=jsonObject.services}catch(e){console.error("Unable to parse response. Make sure catalog has correct format.");catalogdata=null}return catalogdata};this._prependAppURL=function(oldURL){if(!oldURL){return this.serviceURI}var newURL=oldURL;var pat=/^https?:\/\//i;if(!pat.test(newURL)){if(newURL.indexOf("/")!==0){newURL="/"+newURL}newURL=this.serviceURI+newURL}return newURL};function _addWithCredentialsAndAccept(xhr,acceptString){try{xhr.withCredentials=true;xhr.setRequestHeader("Accept",acceptString)}catch(e){}}function _make_basic_auth(user,pw){var tok=user+":"+pw;var hash=btoa(tok);return"Basic "+hash}var loginFormIDString="j_spring_security_check";function _gotLoginForm(xhr){return _findStringInResponseHTML(xhr,loginFormIDString)}var loginFailureIdentificationString="login failed";function _gotLoginFailure(xhr){return _findStringInResponseHTML(xhr,loginFailureIdentificationString)}function _findStringInResponseHTML(xhr,searchString){if(!xhr.responseText){return false}var contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("text/html")>=0&&xhr.responseText.indexOf(searchString)>=0){return true}return false}function handleJSONLoginResponse(params){var jsonObject;params.statusFromjson=null;try{jsonObject=JSON.parse(params.xhr.responseText);if(jsonObject.status_code!==undefined&&jsonObject.status_txt!==undefined){params.statusFromjson=jsonObject.status_code}}catch(e){setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,params.session);setLoginHttpStatus(params.xhr.status,params.session);throw new Error("Unable to parse login response from server.")}}function setRequestHeaderFromContextProps(session,xhr){if(session.xClientProps){xhr.setRequestHeader("X-CLIENT-PROPS",session.xClientProps)}else if(session._contextProperties.contextHeader!==undefined){xhr.setRequestHeader("X-CLIENT-PROPS",session._contextProperties.contextHeader)}}function toggleOnlineState(xhr){var pdsession=that;setLoginHttpStatus(xhr.status,pdsession);if(pdsession.loginHttpStatus>=200&&pdsession.loginHttpStatus<400){setLoginResult(progress.data.Session.LOGIN_SUCCESS,pdsession);setRestApplicationIsOnline(true);pdsession._saveClientContextId(xhr);storeAllSessionInfo()}else{if(pdsession.loginHttpStatus===0||pdsession.loginHttpStatus===400||pdsession.loginHttpStatus===410){setRestApplicationIsOnline(false);setLoginResult(progress.data.AuthenticationProvider._getAuthFailureReason(xhr),pdsession)}else{setRestApplicationIsOnline(true);setLoginResult(progress.data.Session.LOGIN_GENERAL_FAILURE,pdsession)}}setLastSessionXHR(xhr,pdsession);updateContextPropsFromResponse(pdsession,xhr);return pdsession.loginResult}function updateContextPropsFromResponse(session,xhr){var contextString,context;if(xhr){contextString=getResponseHeaderNoError(xhr,"X-CLIENT-PROPS");if(contextString){try{context=JSON.parse(contextString)}catch(e){}if(typeof context==="object"){session._contextProperties.setContext(context)}else{throw new Error(progress.data._getMsgText("jsdoMSG123","Session","X-CLIENT-PROPS"))}}else if(contextString===""){session._contextProperties.setContext({})}}}function cleanServicesManager(){progress.data.ServicesManager.cleanSession(that)}if(typeof options==="object"){jsdosession=options.jsdosession;newURI=options.serviceURI;setAuthProvider(options.authProvider);if(options.authProvider&&options.authProvider.hasClientCredentials()){_loginResult=progress.data.Session.LOGIN_SUCCESS}if(newURI&&newURI[newURI.length-1]==="/"){newURI=newURI.substring(0,newURI.length-1)}_storageKey=options._storageKey;if(_storageKey){if(retrieveSessionInfo(_storageKey)){storedAuthModel=retrieveSessionInfo("authenticationModel");storedURI=retrieveSessionInfo("serviceURI");if(storedAuthModel!==options.authenticationModel||storedURI!==newURI){clearAllSessionInfo()}else{setSessionInfoFromStorage(_storageKey);stateWasReadFromStorage=true}}if(options.authenticationModel===progress.data.Session.AUTH_TYPE_BASIC){_storageKey=undefined}}if(!stateWasReadFromStorage){if(newURI){setServiceURI(newURI,this)}if(options.authenticationModel){this.authenticationModel=options.authenticationModel}}}};progress.data.Session._useTimeStamp=true;var SEQ_MAX_VALUE=999999999999999;var _tsseq=SEQ_MAX_VALUE;var _tsprefix1=0;var _tsprefix2=0;progress.data.Session._getNextTimeStamp=function(){var seq;_tsseq+=1;seq=_tsseq;if(seq>=SEQ_MAX_VALUE){_tsseq=1;seq=1;var t=Math.floor((Date.now?Date.now():(new Date).getTime())/1e4);if(_tsprefix1===t){_tsprefix2+=1;if(_tsprefix2>=SEQ_MAX_VALUE){_tsprefix2=1}}else{_tsprefix1=t;Math.random();_tsprefix2=Math.round(Math.random()*1e10)}}return _tsprefix1+"-"+_tsprefix2+"-"+seq};progress.data.Session._addTimeStampToURL=function(url){var timeStamp="_ts="+progress.data.Session._getNextTimeStamp();url+=(url.indexOf("?")===-1?"?":"&")+timeStamp;return url};progress.data.Session._setNoCacheHeaders=function(xhr){xhr.setRequestHeader("Cache-Control","no-cache");xhr.setRequestHeader("Pragma","no-cache")};if(typeof Object.defineProperty==="function"){Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_REQUIRED",{value:0,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"LOGIN_GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"CATALOG_ALREADY_LOADED",{value:4,enumerable:true});Object.defineProperty(progress.data.Session,"ASYNC_PENDING",{value:5,enumerable:true});Object.defineProperty(progress.data.Session,"EXPIRED_TOKEN",{value:6,enumerable:true});Object.defineProperty(progress.data.Session,"SUCCESS",{value:1,enumerable:true});Object.defineProperty(progress.data.Session,"AUTHENTICATION_FAILURE",{value:2,enumerable:true});Object.defineProperty(progress.data.Session,"GENERAL_FAILURE",{value:3,enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_ANON",{value:"anonymous",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_BASIC",{value:"basic",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM",{value:"form",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_SSO",{value:"sso",enumerable:true});Object.defineProperty(progress.data.Session,"AUTH_TYPE_FORM_SSO",{value:"form_sso",enumerable:true});Object.defineProperty(progress.data.Session,"DEVICE_OFFLINE",{value:"Device is offline",enumerable:true});Object.defineProperty(progress.data.Session,"SERVER_OFFLINE",{value:"Cannot contact server",enumerable:true});Object.defineProperty(progress.data.Session,"WEB_APPLICATION_OFFLINE",{value:"Mobile Web Application is not available",enumerable:true});Object.defineProperty(progress.data.Session,"SERVICE_OFFLINE",{value:"REST web Service is not available",enumerable:true});Object.defineProperty(progress.data.Session,"APPSERVER_OFFLINE",{value:"AppServer is not available",enumerable:true})}else{progress.data.Session.LOGIN_SUCCESS=1;progress.data.Session.LOGIN_AUTHENTICATION_FAILURE=2;progress.data.Session.LOGIN_GENERAL_FAILURE=3;progress.data.Session.CATALOG_ALREADY_LOADED=4;progress.data.Session.SUCCESS=1;progress.data.Session.AUTHENTICATION_FAILURE=2;progress.data.Session.GENERAL_FAILURE=3;progress.data.Session.AUTH_TYPE_ANON="anonymous";progress.data.Session.AUTH_TYPE_BASIC="basic";progress.data.Session.AUTH_TYPE_FORM="form";progress.data.Session.AUTH_TYPE_SSO="sso"}progress.data.Session.prototype=new progress.util.Observable;progress.data.Session.prototype.constructor=progress.data.Session;function validateSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}else{listenerData.scope=args[2]}}}progress.data.Session.prototype._eventNames=["offline","online","afterLogin","afterAddCatalog","afterLogout","afterDisconnect"];progress.data.Session.prototype.validateSubscribe=validateSessionSubscribe;progress.data.Session.prototype.toString=function(radix){return"progress.data.Session"};progress.data.JSDOSession=function JSDOSession(options){var _pdsession,_serviceURI,that=this,_name;Object.defineProperty(this,"authenticationModel",{get:function(){return _pdsession?_pdsession.authenticationModel:undefined},enumerable:true});Object.defineProperty(this,"authProvider",{get:function(){return _pdsession?_pdsession._authProvider:null},enumerable:true});Object.defineProperty(this,"catalogURIs",{get:function(){return _pdsession?_pdsession.catalogURIs:undefined},enumerable:true});Object.defineProperty(this,"clientContextId",{get:function(){return _pdsession?_pdsession.clientContextId:undefined},enumerable:true});Object.defineProperty(this,"connected",{get:function(){return _pdsession?_pdsession.connected:undefined},enumerable:true});Object.defineProperty(this,"JSDOs",{get:function(){return _pdsession?_pdsession.JSDOs:undefined},enumerable:true});Object.defineProperty(this,"loginResult",{get:function(){return _pdsession?_pdsession.loginResult:undefined},enumerable:true});Object.defineProperty(this,"loginHttpStatus",{get:function(){return _pdsession?_pdsession.loginHttpStatus:undefined},enumerable:true});Object.defineProperty(this,"onOpenRequest",{get:function(){return _pdsession?_pdsession.onOpenRequest:undefined},set:function(newval){if(_pdsession){_pdsession.onOpenRequest=newval}},enumerable:true});Object.defineProperty(this,"pingInterval",{get:function(){return _pdsession?_pdsession.pingInterval:undefined},set:function(newval){if(_pdsession){_pdsession.pingInterval=newval}},enumerable:true});Object.defineProperty(this,"services",{get:function(){return _pdsession?_pdsession.services:undefined},enumerable:true});Object.defineProperty(this,"serviceURI",{get:function(){if(_pdsession&&_pdsession.serviceURI){return _pdsession.serviceURI}else{return _serviceURI}},enumerable:true});Object.defineProperty(this,"userName",{get:function(){return _pdsession?_pdsession.userName:undefined},enumerable:true});Object.defineProperty(this,"name",{get:function(){return _name},enumerable:true});Object.defineProperty(this,"_isInvalidated",{get:function(){return _pdsession._isInvalidated},enumerable:false});function settlePromise(promise,fulfill,result,info){if(fulfill){promise.resolve(that,result,info)}else{promise.reject(that,result,info)}}function genericSessionEventHandler(pdsession,result,errorObject,xhr,deferred){var myDeferred;if(xhr){myDeferred=xhr._deferred}else{myDeferred=deferred}settlePromise(myDeferred,result===progress.data.Session.SUCCESS?true:false,result,{errorObject:errorObject,xhr:xhr})}function onAfterAddCatalog(pdsession,result,errorObject,xhr){var deferred,fulfill=false,settleResult,info;if(result===progress.data.Session.EXPIRED_TOKEN){settleResult=progress.data.Session.EXPIRED_TOKEN}else if(result===progress.data.Session.LOGIN_AUTHENTICATION_FAILURE){settleResult=progress.data.Session.LOGIN_AUTHENTICATION_FAILURE}else{settleResult=progress.data.Session.GENERAL_FAILURE}if(xhr&&xhr._deferred){deferred=xhr._deferred;if(result!==progress.data.Session.SUCCESS&&result!==progress.data.Session.CATALOG_ALREADY_LOADED){result=result||progress.data.Session.GENERAL_FAILURE;deferred._overallCatalogResult=progress.data.Session.GENERAL_FAILURE}deferred._results[xhr._catalogIndex]={catalogURI:xhr._catalogURI,result:result,errorObject:errorObject,xhr:xhr};deferred._numCatalogsProcessed+=1;if(deferred._numCatalogsProcessed===deferred._numCatalogs){deferred._processedPromise=true;if(!deferred._overallCatalogResult){fulfill=true;settleResult=progress.data.Session.SUCCESS}if(settleResult===progress.data.Session.SUCCESS){if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,details:xhr._deferred._results}}}else{if(xhr._deferred._results.length===1){info=xhr._deferred._results[0]}else{info={xhr:xhr,result:settleResult,errorObject:new Error(progress.data._getMsgText("jsdoMSG512")),details:xhr._deferred._results}}}settlePromise(xhr._deferred,fulfill,settleResult,info)}}}function onAfterLogout(pdsession,errorObject,xhr){var result=progress.data.Session.GENERAL_FAILURE,fulfill=false;if(xhr&&xhr._deferred){if(!errorObject&&!pdsession.loginResult){result=progress.data.Session.SUCCESS;fulfill=true}settlePromise(xhr._deferred,fulfill,result,{errorObject:errorObject,xhr:xhr})}}function onPingComplete(args){var xhr=args.xhr;if(xhr&&xhr._deferred){settlePromise(xhr._deferred,args.pingResult,args.pingResult,{offlineReason:args.offlineReason,xhr:xhr})}}this.login=function(username,password,options){var deferred=new progress.util.Deferred,iOSBasicAuthTimeout;function callIsAuthorized(){that.isAuthorized().then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(that,object.result,object.info)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG057","JSDOSession","login()"))}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout}if(!_pdsession._authProvider){_pdsession._authProvider=new progress.data.AuthenticationProvider({uri:this.serviceURI,authenticationModel:this.authenticationModel});_pdsession._authProvider.logout().then(function(){return _pdsession._authProvider.login(username,password)}).then(function(){callIsAuthorized()},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(that,object.result,object.info)})}else{throw new Error(progress.data._getMsgText("jsdoMSG062","JSDOSession","login()"))}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.disconnect=function(){var deferred=new progress.util.Deferred,errorObject;try{_pdsession.subscribe("afterDisconnect",genericSessionEventHandler,this);_pdsession._disconnect(deferred)}catch(e){errorObject=new Error(progress.data._getMsgText("jsdoMSG049","JSDOSession","disconnect",e.message))}if(errorObject){if(progress.util.Deferred.useJQueryPromises){throw errorObject}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:errorObject})}}else{return deferred.promise()}};this.addCatalog=function(catalogURI,unameOrOpts,password,opts){var deferred=new progress.util.Deferred,catalogURIs,numCatalogs,catalogIndex,addResult,errorObject,iOSBasicAuthTimeout,username,options,authProvider;try{if(this._isInvalidated){throw new Error(progress.data._getMsgText("jsdoMSG510","JSDOSession"))}if(typeof catalogURI==="string"){catalogURIs=[catalogURI]}else if(catalogURI instanceof Array){catalogURIs=catalogURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","addCatalog","The first argument must be a string or an array of strings specifying the URI of the catalog."))}if(unameOrOpts){if(typeof unameOrOpts==="string"){if(this.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG058","Session"))}username=unameOrOpts;if(opts){options=opts;options.authProvider=undefined}}else if(typeof unameOrOpts==="object"){options=unameOrOpts}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDOSession","2","object","addCatalog"))}}if(typeof options==="object"){iOSBasicAuthTimeout=options.iOSBasicAuthTimeout;if(options.authProvider){authProvider=options.authProvider}else if(this.authProvider){authProvider=this.authProvider}}if(!authProvider&&!this.authProvider&&!username){throw new Error(progress.data._getMsgText("jsdoMSG511"))}_pdsession.subscribe("afterAddCatalog",onAfterAddCatalog,this);numCatalogs=catalogURIs.length;deferred._numCatalogs=numCatalogs;deferred._numCatalogsProcessed=0;deferred._results=[];deferred._results.length=numCatalogs;for(catalogIndex=0;catalogIndex=200&&xhr.status<300){deferred.resolve(that,progress.data.Session.SUCCESS,info)}else{if(xhr.status===401){cbresult=progress.data.AuthenticationProvider._getAuthFailureReason(xhr)}else{cbresult=progress.data.Session.GENERAL_FAILURE}deferred.reject(that,cbresult,info)}}};try{xhr.send()}catch(e){throw new Error("JSDOSession: Unable to validate authorization. "+e.message)}})}else{result=progress.data.Session.LOGIN_AUTHENTICATION_REQUIRED;deferred.reject(that,result,{xhr:xhr})}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(that,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.setContext=function(context){_pdsession._contextProperties.setContext(context)};this.setContextProperty=function(propertyName,propertyValue){_pdsession._contextProperties.setContextProperty(propertyName,propertyValue)};this.getContext=function(){return _pdsession._contextProperties.getContext()};this.getContextProperty=function(propertyName){return _pdsession._contextProperties.getContextProperty(propertyName)};this._onlineHandler=function(session,request){that.trigger("online",that,request)};this._offlineHandler=function(session,offlineReason,request){that.trigger("offline",that,offlineReason,request)};if(arguments.length>0&&typeof arguments[0]==="object"){if(options.serviceURI&&typeof options.serviceURI==="string"){_serviceURI=options.serviceURI}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options parameter must include a 'serviceURI' property that is a string."))}if(options.authenticationModel){if(typeof options.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The authenticationModel property of the options parameter must be a string."))}options.authenticationModel=options.authenticationModel.toLowerCase()}else{options.authenticationModel=progress.data.Session.AUTH_TYPE_ANON}if(options.authProvider){if(typeof options.authProvider!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG502","JSDOSession","options","constructor","authProvider"))}if(options.authProvider.authenticationModel!==progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authProvider.authenticationModel!==options.authenticationModel||options.authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_FORM_SSO&&options.authenticationModel!==progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG059","JSDOSession",options.authProvider.authenticationModel,options.authenticationModel))}if(typeof options.authProvider.hasClientCredentials==="function"){if(!options.authProvider.hasClientCredentials()){throw new Error(progress.data._getMsgText("jsdoMSG125","JSDOSession"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG505","JSDOSession","AuthenticationProvider","hasClientCredentials"))}}else if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){throw new Error(progress.data._getMsgText("jsdoMSG508"))}}else{throw new Error(progress.data._getMsgText("jsdoMSG033","JSDOSession","the constructor","The options argument was missing or invalid."))}_name=options.name;_pdsession=new progress.data.Session({_storageKey:_name,_silent:true,authenticationModel:options.authenticationModel,serviceURI:options.serviceURI,jsdosession:this,authProvider:options.authProvider});try{if(options.context){this.setContext(options.context)}_pdsession.subscribe("online",this._onlineHandler,this);_pdsession.subscribe("offline",this._offlineHandler,this)}catch(err){_pdsession=undefined;throw err}};progress.data.JSDOSession.prototype=new progress.util.Observable;progress.data.JSDOSession.prototype.constructor=progress.data.JSDOSession;function validateJSDOSessionSubscribe(args,evt,listenerData){listenerData.operation=undefined;var found=false;this._eventNames.forEach(function(eventName){if(evt===eventName.toLowerCase()){found=true}});if(!found){throw new Error(progress.data._getMsgText("jsdoMSG042",evt))}if(args.length<2){throw new Error(progress.data._getMsgText("jsdoMSG038",2))}if(typeof args[0]!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG039"))}if(typeof args[1]!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG040"))}listenerData.fn=args[1];if(args.length>2){if(typeof args[2]!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG041",evt))}listenerData.scope=args[2]}}progress.data.JSDOSession.prototype._eventNames=["offline","online"];progress.data.JSDOSession.prototype.validateSubscribe=validateJSDOSessionSubscribe;progress.data.JSDOSession.prototype.toString=function(radix){return"progress.data.JSDOSession"};progress.data.getSession=function(options){var deferred=new progress.util.Deferred,authProvider,promise,authProviderInitObject={};function sessionRejectHandler(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);if(authProvider&&authProvider.hasClientCredentials()){var callback=function(){deferred.reject(object.result,object.info)};authProvider.logout().then(callback,callback)}else{deferred.reject(object.result,object.info)}}function callbackRejectHandler(reason){deferred.reject(progress.data.Session.GENERAL_FAILURE,{reason:reason})}function loginHandler(object){var jsdosession;try{jsdosession=new progress.data.JSDOSession(options);try{jsdosession.isAuthorized().then(function(){return jsdosession.addCatalog(options.catalogURI)},sessionRejectHandler).then(function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.resolve(object.jsdosession,progress.data.Session.SUCCESS)},sessionRejectHandler)}catch(e){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}catch(ex){sessionRejectHandler(jsdosession,progress.data.Session.GENERAL_FAILURE,{errorObject:ex})}}function callLogin(provider){var errorObject;if(typeof options.loginCallback!=="undefined"){options.loginCallback().then(function(result){try{provider.login(result.username,result.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}},callbackRejectHandler)}else if(options.username&&options.password){try{provider.login(options.username,options.password).then(loginHandler,sessionRejectHandler)}catch(e){sessionRejectHandler(provider,progress.data.Session.GENERAL_FAILURE,{errorObject:e})}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG052","getSession()"));sessionRejectHandler(provider,progress.data.Session.AUTHENTICATION_FAILURE,{errorObject:errorObject})}}if(typeof options!=="object"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options","object"))}if(typeof options.loginCallback!=="undefined"&&typeof options.loginCallback!=="function"){throw new Error(progress.data._getMsgText("jsdoMSG503","getSession()","options.loginCallback","function"))}try{if(options.authenticationModel===progress.data.Session.AUTH_TYPE_SSO){if(!options.authenticationURI||!options.authProviderAuthenticationModel){throw new Error(progress.data._getMsgText("jsdoMSG509"))}}if(options.authenticationURI){authProviderInitObject.uri=options.authenticationURI;authProviderInitObject.authenticationModel=options.authProviderAuthenticationModel;if(typeof authProviderInitObject.authenticationModel!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG502","progress.data.getSession","object","getSession","authProviderAuthenticationModel"))}}else{authProviderInitObject.uri=options.serviceURI;authProviderInitObject.authenticationModel=options.authenticationModel}authProvider=new progress.data.AuthenticationProvider(authProviderInitObject);options.authProvider=authProvider;if(authProvider.hasClientCredentials()){loginHandler(authProvider)}else{if(authProvider.authenticationModel===progress.data.Session.AUTH_TYPE_ANON){authProvider.login().then(loginHandler,sessionRejectHandler)}else{callLogin(authProvider)}}}catch(error){sessionRejectHandler(null,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}return deferred.promise()};progress.data.invalidateAllSessions=function(){var jsdosession,key,deferred=new progress.util.Deferred,jsdosessions=progress.data.ServicesManager._jsdosessions,invalidatePromises=[];try{for(key in jsdosessions){if(jsdosessions.hasOwnProperty(key)){jsdosession=jsdosessions[key];invalidatePromises.push(jsdosession.invalidate())}}progress.util.Deferred.when(invalidatePromises).then(function(){deferred.resolve(progress.data.Session.SUCCESS)},function(object,result,info){object=progress.util.Deferred.getParamObject(object,result,info);deferred.reject(progress.data.Session.GENERAL_FAILURE,info)})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()}})();if(typeof exports!=="undefined"){exports.progress=progress}(function(){"use strict";if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data.AuthenticationProvider=function AuthenticationProvider(initObject){var authProv,authModel,uri;if(typeof initObject==="object"){this._checkStringArg("constructor",initObject.authenticationModel,"initObject.authenticationModel","initObject.authenticationModel");this._checkStringArg("constructor",initObject.uri,"init-object.uri","init-object.uri")}else{throw new Error(progress.data._getMsgText("jsdoMSG033","AuthenticationProvider","the constructor","The init-object argument was missing or invalid."))}authModel=initObject.authenticationModel.toLowerCase();switch(authModel){case progress.data.Session.AUTH_TYPE_ANON:this._initialize(initObject.uri,progress.data.Session.AUTH_TYPE_ANON,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});authProv=this;break;case progress.data.Session.AUTH_TYPE_BASIC:authProv=new progress.data.AuthenticationProviderBasic(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM:authProv=new progress.data.AuthenticationProviderForm(initObject.uri);break;case progress.data.Session.AUTH_TYPE_FORM_SSO:authProv=new progress.data.AuthenticationProviderSSO(initObject.uri);break;default:throw new Error(progress.data._getMsgText("jsdoMSG502","AuthenticationProvider","init-object","constructor","authenticationModel"))}return authProv};progress.data.AuthenticationProvider.prototype._loginProto=function(sendParam){var deferred=new progress.util.Deferred,xhr,uriForRequest,header,that=this;try{if(this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG051","AuthenticationProvider"))}xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLoginResult(xhr,deferred)}};if(progress.data.Session._useTimeStamp){uriForRequest=progress.data.Session._addTimeStampToURL(this._loginURI)}else{uriForRequest=this._loginURI}this._openLoginRequest(xhr,uriForRequest);xhr.setRequestHeader("Accept","application/json");xhr.send(sendParam)}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.login=function(){return this._loginProto()};progress.data.AuthenticationProvider.prototype._openLoginRequest=function(xhr,uri){xhr.open("GET",uri,true);progress.data.Session._setNoCacheHeaders(xhr)};progress.data.AuthenticationProvider.prototype._processLoginResult=function(xhr,deferred){var result;if(xhr.status===200){this._loggedIn=true;this._storeInfo();result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};progress.data.AuthenticationProvider.prototype.logout=function(){var deferred=new progress.util.Deferred;try{this._reset();deferred.resolve(this,progress.data.Session.SUCCESS,{})}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProvider.prototype.hasClientCredentials=function(){return this._loggedIn};progress.data.AuthenticationProvider.prototype.hasRefreshToken=function(){return false};progress.data.AuthenticationProvider.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);xhr.setRequestHeader("Accept","application/json");callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};progress.data.AuthenticationProvider.prototype._initialize=function(uriParam,authModel,targetURIs){var tempURI,target;Object.defineProperty(this,"uri",{get:function(){return this._uri},enumerable:true});Object.defineProperty(this,"authenticationModel",{get:function(){return this._authenticationModel},enumerable:true});if(uriParam[uriParam.length-1]==="/"){tempURI=uriParam.substring(0,uriParam.length-1)}else{tempURI=uriParam}for(target in targetURIs){if(targetURIs.hasOwnProperty(target)){this[target]=tempURI+targetURIs[target]}}this._authenticationModel=authModel;this._uri=uriParam;this._loggedIn=false;this._dataKeys={uri:".uri",loggedIn:".loggedIn"};if(typeof sessionStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","AuthenticationProvider","sessionStorage"))}this._storage=sessionStorage;this._storageKey=this._uri;this._dataKeys.uri=this._storageKey+this._dataKeys.uri;this._dataKeys.loggedIn=this._storageKey+this._dataKeys.loggedIn;if(this._retrieveLoggedIn()){this._loggedIn=true}};progress.data.AuthenticationProvider.prototype._storeInfo=function(){this._storage.setItem(this._dataKeys.uri,JSON.stringify(this._uri));this._storage.setItem(this._dataKeys.loggedIn,JSON.stringify(this._loggedIn))};progress.data.AuthenticationProvider.prototype._retrieveInfoItem=function(propName){var jsonStr=this._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value};progress.data.AuthenticationProvider.prototype._retrieveURI=function(){return this._retrieveInfoItem(this._dataKeys.uri)};progress.data.AuthenticationProvider.prototype._retrieveLoggedIn=function(){return this._retrieveInfoItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._clearInfo=function(info){this._storage.removeItem(this._dataKeys.uri);this._storage.removeItem(this._dataKeys.loggedIn)};progress.data.AuthenticationProvider.prototype._reset=function(){this._clearInfo();this._loggedIn=false};progress.data.AuthenticationProvider.prototype._settlePromise=function(deferred,result,info){if(result===progress.data.Session.SUCCESS){deferred.resolve(this,result,info)}else{deferred.reject(this,result,info)}};progress.data.AuthenticationProvider.prototype._checkStringArg=function(fnName,argToCheck,argPosition,argName){if(typeof argToCheck!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","AuthenticationProvider",argPosition,"string",fnName))}else if(argToCheck.length===0){throw new Error(progress.data._getMsgText("jsdoMSG501","AuthenticationProvider",argName,fnName))}};progress.data.AuthenticationProvider._getAuthFailureReason=function(xhr){var contentType,jsonObject,result=progress.data.Session.AUTHENTICATION_FAILURE;if(xhr.status===401){contentType=xhr.getResponseHeader("Content-Type");if(contentType&&contentType.indexOf("application/json")>-1&&xhr.responseText){jsonObject=JSON.parse(xhr.responseText);if(jsonObject.error==="sso.token.expired_token"){result=progress.data.Session.EXPIRED_TOKEN}}}else{result=null}return result};Object.defineProperty(progress.data.AuthenticationProvider,"_homeLoginURIBase",{value:"/static/home.html",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLoginURIBase",{value:"/static/auth/j_spring_security_check",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springLogoutURIBase",{value:"/static/auth/j_spring_security_logout",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenLoginURIBase",{value:progress.data.AuthenticationProvider._springLoginURIBase+"?OECP=yes",enumerable:true});Object.defineProperty(progress.data.AuthenticationProvider,"_springFormTokenRefreshURIBase",{value:"/static/auth/token?op=refresh",enumerable:true})})();(function(){"use strict";progress.data.AuthenticationProviderBasic=function(uri){var defaultiOSBasicAuthTimeout,userName=null,password=null,fn;this._initialize(uri,progress.data.Session.AUTH_TYPE_BASIC,{_loginURI:progress.data.AuthenticationProvider._homeLoginURIBase});this._reset();function make_basic_auth_header(user,pw){var tok=user+":"+pw,hash=btoa(tok);return"Basic "+hash}this._reset=function(){userName=null;password=null;progress.data.AuthenticationProviderBasic.prototype._reset.apply(this)};this._openLoginRequest=function(xhr,uri){var auth;xhr.open("GET",uri,true);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr)};this._processLoginResult=function _basic_processLoginResult(xhr,deferred){progress.data.AuthenticationProviderBasic.prototype._processLoginResult.apply(this,[xhr,deferred]);if(!this._loggedIn){userName=null;password=null}};this.login=function(userNameParam,passwordParam){this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");userName=userNameParam;password=passwordParam;return this._loginProto()};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var auth,errorObject;if(this.hasClientCredentials()){xhr.open(verb,uri,async);if(userName){auth=make_basic_auth_header(userName,password);xhr.setRequestHeader("Authorization",auth)}progress.data.Session._setNoCacheHeaders(xhr);callback(xhr)}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}}};function BasicProxy(){}BasicProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderBasic.prototype=new BasicProxy;progress.data.AuthenticationProviderBasic.prototype.constructor=progress.data.AuthenticationProviderBasic})();(function(){"use strict";var fn;progress.data.AuthenticationProviderForm=function(uri){this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM,{_loginURI:progress.data.AuthenticationProvider._springLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase})};function FormProxy(){}FormProxy.prototype=progress.data.AuthenticationProvider.prototype;progress.data.AuthenticationProviderForm.prototype=new FormProxy;progress.data.AuthenticationProviderForm.prototype.constructor=progress.data.AuthenticationProviderForm;progress.data.AuthenticationProviderForm.prototype.login=function(userNameParam,passwordParam){var deferred=new progress.util.Deferred,xhr,that=this;this._checkStringArg("login",userNameParam,1,"userName");this._checkStringArg("login",passwordParam,2,"password");return this._loginProto("j_username="+encodeURIComponent(userNameParam)+"&j_password="+encodeURIComponent(passwordParam)+"&submit=Submit")};progress.data.AuthenticationProviderForm.prototype._openLoginRequest=function(xhr,uri){xhr.open("POST",uri,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.setRequestHeader("Pragma","no-cache");xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.withCredentials=true};progress.data.AuthenticationProviderForm.prototype.logout=function(){var deferred=new progress.util.Deferred,xhr,that=this;try{if(!this._loggedIn){deferred.resolve(this,progress.data.Session.SUCCESS,{})}else{xhr=new XMLHttpRequest;this._openLogoutRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){that._processLogoutResult(xhr,deferred)}};xhr.send()}this._reset()}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};progress.data.AuthenticationProviderForm.prototype._openLogoutRequest=function(xhr){xhr.open("GET",this._logoutURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Accept","application/json")};progress.data.AuthenticationProviderForm.prototype._processLogoutResult=function(xhr,deferred){var result;if(xhr.status===200){result=progress.data.Session.SUCCESS}else if(xhr.status===401){result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};fn=progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize;progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){function afterSuper(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.withCredentials=true;callback(xhr)}}try{progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super.apply(this,[xhr,verb,uri,async,afterSuper])}catch(e){callback(e)}};progress.data.AuthenticationProviderForm.prototype._openRequestAndAuthorize._super=fn})();(function(){"use strict";var fn;progress.data.AuthenticationProviderSSO=function(uri){var that=this,_automaticTokenRefresh,temp,ssoTokenInfo=null,tokenDataKeys={token:".access_token",refreshToken:".refresh_token",tokenType:".token_type",expiration:".expires_in",accessTokenExpiration:".accessTokenExpiration"};function storeTokenInfo(info){var date,accessTokenExpiration;if(info.access_token.length){that._storage.setItem(tokenDataKeys.token,JSON.stringify(info.access_token))}if(info.refresh_token.length){that._storage.setItem(tokenDataKeys.refreshToken,JSON.stringify(info.refresh_token));date=new Date;accessTokenExpiration=date.getTime()+info.expires_in*1e3*.75;that._storage.setItem(tokenDataKeys.accessTokenExpiration,JSON.stringify(accessTokenExpiration))}else{that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}that._storage.setItem(tokenDataKeys.tokenType,JSON.stringify(info.token_type));that._storage.setItem(tokenDataKeys.expiration,JSON.stringify(info.expires_in))}function retrieveTokenProperty(propName){var jsonStr=that._storage.getItem(propName),value=null;if(jsonStr!==null){try{value=JSON.parse(jsonStr)}catch(e){value=null}}return value}function retrieveToken(){return retrieveTokenProperty(tokenDataKeys.token)}function retrieveRefreshToken(){return retrieveTokenProperty(tokenDataKeys.refreshToken)}function retrieveAccessTokenExpiration(){return retrieveTokenProperty(tokenDataKeys.accessTokenExpiration)}function retrieveTokenType(){return retrieveTokenProperty(tokenDataKeys.tokenType)}function getToken(){return retrieveToken()}function retrieveExpiration(){return retrieveTokenProperty(tokenDataKeys.expiration)}function clearTokenInfo(info){that._storage.removeItem(tokenDataKeys.token);that._storage.removeItem(tokenDataKeys.refreshToken);that._storage.removeItem(tokenDataKeys.tokenType);that._storage.removeItem(tokenDataKeys.expiration);that._storage.removeItem(tokenDataKeys.accessTokenExpiration)}function openRefreshRequest(xhr){xhr.open("POST",that._refreshURI,true);xhr.setRequestHeader("Cache-Control","max-age=0");xhr.withCredentials=true;xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Accept","application/json")}function processRefreshResult(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","refresh",ex.message))}}else if(xhr.status===401){that._reset();result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}that._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})}this._processLoginResult=function(xhr,deferred){var errorObject,result,ssoTokenJSON;if(xhr.status===200){this._loggedIn=true;try{ssoTokenInfo=JSON.parse(xhr.responseText);if(ssoTokenInfo.access_token){storeTokenInfo(ssoTokenInfo);result=progress.data.Session.SUCCESS}else{result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",progress.data._getMsgText("jsdoMSG050")))}}catch(ex){result=progress.data.Session.GENERAL_FAILURE;errorObject=new Error(progress.data._getMsgText("jsdoMSG049","AuthenticationProvider","login",ex.message))}if(result!==progress.data.Session.SUCCESS){var callback=function(params){params=progress.util.Deferred.getParamObject(params);params.provider._settlePromise(deferred,result,{xhr:xhr,errorObject:errorObject})};this.logout().then(callback,callback);return}}else if(xhr.status===401){result=progress.data.Session.AUTHENTICATION_FAILURE}else{result=progress.data.Session.GENERAL_FAILURE}this._settlePromise(deferred,result,{xhr:xhr})};this._reset=function(){progress.data.AuthenticationProviderSSO.prototype._reset.apply(this);clearTokenInfo();ssoTokenInfo=null};this._openRequestAndAuthorize=function(xhr,verb,uri,async,callback){var that=this,date,errorObject;function afterRefreshCheck(provider,result,info){if(result===progress.data.Session.AUTHENTICATION_FAILURE){callback(new Error(progress.data._getMsgText("jsdoMSG060")))}else{progress.data.AuthenticationProviderSSO.prototype._openRequestAndAuthorize.apply(that,[xhr,verb,uri,async,function(errorObject){if(errorObject instanceof Error){callback(errorObject)}else{xhr.setRequestHeader("Authorization","oecp "+getToken());callback(xhr)}}])}}if(this.hasClientCredentials()){date=new Date;if(this.automaticTokenRefresh&&this.hasRefreshToken()&&date.getTime()>retrieveAccessTokenExpiration()){try{var callback=function(params,result,info){params=progress.util.Deferred.getParamObject(params,result,info);afterRefreshCheck(params.provider,params.result,params.info)};this.refresh().then(callback,callback)}catch(e){callback(e)}}else{afterRefreshCheck(this,progress.data.Session.SUCCESS,null)}}else{errorObject=new Error(progress.data._getMsgText("jsdoMSG125","AuthenticationProvider"));callback(errorObject)}};this.hasClientCredentials=function(){return retrieveToken()===null?false:true};this.refresh=function(){var deferred=new progress.util.Deferred,xhr;try{if(!this._loggedIn){throw new Error(progress.data._getMsgText("jsdoMSG053","AuthenticationProvider","refresh"))}if(!this.hasRefreshToken()){throw new Error(progress.data._getMsgText("jsdoMSG054","AuthenticationProvider"))}xhr=new XMLHttpRequest;openRefreshRequest(xhr);xhr.onreadystatechange=function(){if(xhr.readyState===4){processRefreshResult(xhr,deferred)}};xhr.send('{"token_type":"'+retrieveTokenType()+'","refresh_token":"'+retrieveRefreshToken()+'"}')}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{deferred.reject(this,progress.data.Session.GENERAL_FAILURE,{errorObject:error})}}return deferred.promise()};this.hasRefreshToken=function(){return retrieveRefreshToken()===null?false:true};this._initialize(uri,progress.data.Session.AUTH_TYPE_FORM_SSO,{_loginURI:progress.data.AuthenticationProvider._springFormTokenLoginURIBase,_logoutURI:progress.data.AuthenticationProvider._springLogoutURIBase,_refreshURI:progress.data.AuthenticationProvider._springFormTokenRefreshURIBase});_automaticTokenRefresh=true;Object.defineProperty(this,"automaticTokenRefresh",{get:function(){return _automaticTokenRefresh},set:function(value){if(value===true||value===false){_automaticTokenRefresh=value}else{throw new Error(progress.data._getMsgText("jsdoMSG061","AuthenticationProvider","automaticTokenRefresh"))}},enumerable:true});this._dataKeys.automaticTokenRefresh=this._storageKey+".automaticTokenRefresh";temp=this._retrieveInfoItem(this._dataKeys.automaticTokenRefresh);if(temp===false){_automaticTokenRefresh=false}tokenDataKeys.token=this._storageKey+tokenDataKeys.token;tokenDataKeys.refreshToken=this._storageKey+tokenDataKeys.refreshToken;tokenDataKeys.tokenType=this._storageKey+tokenDataKeys.tokenType;tokenDataKeys.expiration=this._storageKey+tokenDataKeys.expiration;tokenDataKeys.accessTokenExpiration=this._storageKey+tokenDataKeys.accessTokenExpiration;if(retrieveToken()){this._loggedIn=true}};function SSOProxy(){}SSOProxy.prototype=progress.data.AuthenticationProviderForm.prototype;progress.data.AuthenticationProviderSSO.prototype=new SSOProxy;progress.data.AuthenticationProviderSSO.prototype.constructor=progress.data.AuthenticationProviderSSO;fn=progress.data.AuthenticationProviderSSO.prototype._storeInfo;progress.data.AuthenticationProviderSSO.prototype._storeInfo=function(){progress.data.AuthenticationProviderSSO.prototype._storeInfo._super.apply(this);this._storage.setItem(this._dataKeys.automaticTokenRefresh,JSON.stringify(this._automaticTokenRefresh))};progress.data.AuthenticationProviderSSO.prototype._storeInfo._super=fn;fn=progress.data.AuthenticationProviderSSO.prototype._clearInfo;progress.data.AuthenticationProviderSSO.prototype._clearInfo=function(){progress.data.AuthenticationProviderSSO.prototype._clearInfo._super.apply(this);this._storage.removeItem(this._dataKeys.automaticTokenRefresh)};progress.data.AuthenticationProviderSSO.prototype._clearInfo._super=fn})();
+(function(){var isNativeScript=false,isNodeJS=false;var pkg_xmlhttprequest="xmlhttprequest",pkg_nodeLocalstorage="node-localstorage",pkg_nativescriptLocalstorage="nativescript-localstorage",pkg_fileSystemAccess="file-system/file-system-access",pkg_base64="base-64";if(typeof XMLHttpRequest==="undefined"){isNodeJS=true;try{XMLHttpRequest=require(""+pkg_xmlhttprequest).XMLHttpRequest}catch(e){console.error("Error: JSDO library requires XMLHttpRequest object in Node.js.\n"+"Please install xmlhttprequest package.")}}if(!isNodeJS&&(typeof localStorage==="undefined"||typeof sessionStorage==="undefined")){try{require(""+pkg_fileSystemAccess);isNativeScript=true}catch(exception1){isNativeScript=false}}if(isNativeScript){try{if(typeof sessionStorage==="undefined"){sessionStorage=require(""+pkg_nativescriptLocalstorage)}if(typeof localStorage==="undefined"){localStorage=require(""+pkg_nativescriptLocalstorage)}}catch(exception2){console.error("Error: JSDO library requires localStorage and sessionStorage objects in NativeScript.\n"+"Please install nativescript-localstorage package.")}try{if(typeof btoa==="undefined"){btoa=require(""+pkg_base64).encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in NativeScript.\n"+"Please install base-64 package.")}}if(isNodeJS){var LocalStorage;if(typeof localStorage==="undefined"){try{var module=require(""+pkg_nodeLocalstorage);LocalStorage=module.LocalStorage;localStorage=new LocalStorage("./scratch1")}catch(e){console.error("Error: JSDO library requires localStorage and sessionStorage objects in Node.js.\n"+"Please install node-localstorage package.")}}if(typeof sessionStorage==="undefined"&&typeof LocalStorage!=="undefined"){sessionStorage=new LocalStorage("./scratch2")}try{if(typeof btoa==="undefined"){btoa=require(""+pkg_base64).encode}}catch(exception3){console.error("Error: JSDO library requires btoa() function in Node.js.\n"+"Please install base-64 package.")}}})();(function(){if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.util={};var STRING_OBJECT_TYPE="String",DATE_OBJECT_TYPE="Date",CHARACTER_ABL_TYPE="CHARACTER";progress.util.Deferred=function(){function Deferred(){this._deferred={}}Deferred.prototype.promise=function(){var that=this;if(progress.util.Deferred.useJQueryPromises){if(typeof $!=="undefined"&&typeof $.Deferred==="function"){this._deferred._jQuerydeferred=$.Deferred();this._promise=this._deferred._jQuerydeferred.promise()}else{throw new Error("JQuery Promises not found in environment.")}}else{this._promise=new Promise(function(resolve,reject){that._deferred.resolve=resolve;that._deferred.reject=reject})}if(this._resolveArguments||this._rejectArguments){setTimeout(function(){if(that._resolveArguments){that.resolve.apply(that,that._resolveArguments)}else if(that._rejectArguments){that.reject.apply(that,that._rejectArguments)}},500)}return this._promise};Deferred.prototype.resolve=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.resolve.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.resolve(object)}}else{this._resolveArguments=arguments}};Deferred.prototype.reject=function(arg1,arg2,arg3){if(this._promise){if(this._deferred._jQuerydeferred){this._deferred._jQuerydeferred.reject.apply(this,arguments)}else{var object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3);this._deferred.reject(object)}}else{this._rejectArguments=arguments}};Deferred.useJQueryPromises=false;Deferred.when=function(deferreds){if(progress.util.Deferred.useJQueryPromises){return $.when.apply($,deferreds)}else{return Promise.all(deferreds)}};Deferred.getParamObject1=function(arg1,arg2,arg3){var object={},objectName;try{if(typeof arg1==="undefined"||arg1===null){object.result=arg2;object.info=arg3}else{if(arg1 instanceof progress.data.JSDOSession){objectName="jsdosession"}else if(arg1 instanceof progress.data.AuthenticationProvider){objectName="provider"}else if(arg1 instanceof progress.data.JSDO){objectName="jsdo"}else if(typeof arg1==="number"){objectName="result"}else{objectName=typeof arg1}object[objectName]=arg1;if(objectName==="jsdo"){object.success=arg2;if(arg3&&arg3.xhr){object.request=arg3}else if(arg3&&arg3.batch){object.request=arg3}else{object.info=arg3}}else{if(objectName==="result"){object.info=arg2;if(arg3){object.info2=arg3}}else{object.result=arg2;object.info=arg3}}}}catch(e){console.log("Error: Undetermined argument in getParamObject() call.")}return object};Deferred.getParamObject=function(arg1,arg2,arg3){var object={};if(progress.util.Deferred.useJQueryPromises){object=progress.util.Deferred.getParamObject1(arg1,arg2,arg3)}else{if(typeof arg1==="undefined"){object.result=arg2;object.info=arg3;arg1=object}return arg1}return object};return Deferred}();progress.util.Observable=function(){function _filterObservers(observers,fn,scope,operation){return observers.filter(function(el){if(el.fn!==fn||el.scope!==scope||el.operation!==operation){return el}},this)}this.validateSubscribe=function(args,evt,listenerData){if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="string"){listenerData.operation=args[1];listenerData.fn=args[2];listenerData.scope=args[3]}else if(args.length>=2&&typeof args[0]==="string"&&typeof args[1]==="function"){listenerData.operation=undefined;listenerData.scope=args[2];listenerData.fn=args[1]}else{throw new Error}};this.subscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"subscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",progress.data._getMsgText("jsdoMSG039")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"subscribe",e.message))}observers=this._events[evt]||[];observers=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation);observers.push(listenerData);this._events[evt]=observers;return this};this.unsubscribe=function(evt,operation,fn,scope){var listenerData,observers;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"unsubscribe"))}if(typeof evt!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",progress.data._getMsgText("jsdoMSG037")))}this._events=this._events||{};evt=evt.toLowerCase();listenerData={fn:undefined,scope:undefined,operation:undefined};try{this.validateSubscribe(arguments,evt,listenerData)}catch(e){throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"unsubscribe",e.message))}observers=this._events[evt]||[];if(observers.length>0){this._events[evt]=_filterObservers(observers,listenerData.fn,listenerData.scope,listenerData.operation)}return this};this.trigger=function(evt,operation,args){var observers,op;if(!evt){throw new Error(progress.data._getMsgText("jsdoMSG037",this.toString(),"trigger"))}this._events=this._events||{};evt=evt.toLowerCase();observers=this._events[evt]||[];if(observers.length>0){args=Array.prototype.slice.call(arguments);if(arguments.length>=2&&typeof evt==="string"&&typeof operation==="string"){op=operation;args=args.length>2?args.slice(2):[]}else if(arguments.length>=1&&typeof evt==="string"){op=undefined;args=args.length>1?args.slice(1):[]}else{throw new Error(progress.data._getMsgText("jsdoMSG033",this.toString(),"trigger"))}observers.forEach(function(el){if(el.operation===op){el.fn.apply(el.scope,args)}})}return this};this.unsubscribeAll=function(evt,operation){var observers;if(evt){this._events=this._events||{};if(typeof evt==="string"){evt=evt.toLowerCase();observers=this._events[evt]||[];observers.forEach(function(el){if(el.operation){this.unsubscribe(evt,el.operation,el.fn,el.scope)}else{this.unsubscribe(evt,el.fn,el.scope)}},this)}}else{this._events={}}return this}};progress.data.LocalStorage=function LocalStorage(){if(typeof localStorage==="undefined"){throw new Error(progress.data._getMsgText("jsdoMSG126","progress.data.LocalStorage","localStorage"))}this.saveToLocalStorage=function(name,dataObj){localStorage.setItem(name,JSON.stringify(dataObj))};this.readFromLocalStorage=function(name){var jsonStr=localStorage.getItem(name),dataObj=null;if(jsonStr!==null){try{dataObj=JSON.parse(jsonStr)}catch(e){dataObj=null}}return dataObj};this.clearLocalStorage=function(name){localStorage.removeItem(name)}};progress.util._convertToABLWhereString=function(tableRef,filter){var result=[],logic=filter.logic||"and",idx,length,field,fieldInfo,type,format,operator,value,ablType,filters=filter.filters||[filter],whereOperators={eq:"=",neq:"<>",gt:">",gte:">=",lt:"<",lte:"<=",contains:"INDEX",doesnotcontain:"INDEX",endswith:"R-INDEX",startswith:"BEGINS",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};for(idx=0,length=filters.length;idx 0"}else{format="{2} MATCHES '*{1}'"}}else{format="{2} {0} "+format}filter=progress.util._format(format,operator,value,field)}else if(operator&&value===undefined){if(filter.operator==="isempty"||filter.operator==="isnotempty"){ablType=tableRef._getABLType(field);if(ablType!==CHARACTER_ABL_TYPE){throw new Error("Error parsing filter object. The operator "+filter.operator+" requires a CHARACTER field")}if(filter.operator==="isempty"){format="{2} = ''"}else if(filter.operator==="isnotempty"){format="{2} <> ''"}}else{if(filter.operator==="isnull"){format="{2} = ?"}else if(filter.operator==="isnotnull"){format="{2} <> ?"}else{format="{2} {0} ?"}}filter=progress.util._format(format,operator,value,field)}}result.push(filter)}filter=result.join(" "+logic+" ");if(result.length>1){filter="("+filter+")"}return filter};progress.util._convertToSQLQueryString=function(tableRef,filter,addSelect){var result=[],logic=filter.logic||"and",idx,length,field,type,format,operator,value,fieldFormat,filters=filter.filters||[filter],filterStr,usingLike=true,whereOperators={eq:"=",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<=",contains:"LIKE",doesnotcontain:"NOT LIKE",endswith:"LIKE",startswith:"LIKE",isnull:"ISNULL",isnotnull:"ISNOTNULL",isempty:"ISEMPTY",isnotempty:"ISNOTEMPTY"};if(typeof addSelect==="undefined"){addSelect=false}for(idx=0,length=filters.length;idx1){filterStr="("+filterStr+")"}if(addSelect===true){filterStr="SELECT * FROM "+tableRef._name+" WHERE "+filterStr}return filterStr};progress.util._getObjectType=function(value){return Object.prototype.toString.call(value).slice(8,-1)};progress.util._format=function(fmt){var values=arguments,formatRegExp=/\{(\d+)(:[^\}]+)?\}/g;return fmt.replace(formatRegExp,function(match,index,placeholderFormat){var value=values[parseInt(index,10)+1];return progress.util._toString(value,placeholderFormat?placeholderFormat.substring(1):"")})};progress.util._toString=function(value,fmt){var str;if(fmt){if(progress.util._getObjectType(value)==="Date"){return progress.util._formatDate(value,fmt)}}if(typeof value==="number"){str=value.toString()}else{str=value!==undefined?value:""}return str};progress.util._pad=function(number,digits){var zeros=["","0","00","000","0000"],end;number=String(number);digits=digits||2;end=digits-number.length;if(end){return zeros[digits].substring(0,end)+number}return number};progress.util._formatDate=function(date,format){var dateFormatRegExp=/dd|MM|yyyy|hh|mm|fff|FFF|ss|zzz|iso|"[^"]*"|'[^']*'/g;return format.replace(dateFormatRegExp,function(match){var minutes,result,sign;if(match==="dd"){result=progress.util._pad(date.getDate())}else if(match==="MM"){result=progress.util._pad(date.getMonth()+1)}else if(match==="yyyy"){result=progress.util._pad(date.getFullYear(),4)}else if(match==="hh"){result=progress.util._pad(date.getHours())}else if(match==="mm"){result=progress.util._pad(date.getMinutes())}else if(match==="ss"){result=progress.util._pad(date.getSeconds())}else if(match==="fff"){result=progress.util._pad(date.getMilliseconds(),3)}else if(match==="FFF"){result=String(date.getTime())}else if(match==="zzz"){minutes=date.getTimezoneOffset();sign=minutes<0;result=(sign?"+":"-")+minutes}else if(match==="iso"){result=date.toISOString()}return result!==undefined?result:match.slice(1,match.length-1)})};progress.util.jsdoSettingsProcessor=function jsdoSettingsProcessor(jsdoSettings){if(typeof jsdoSettings==="object"){if(jsdoSettings.authenticationModel===undefined||jsdoSettings.authenticationModel===""){jsdoSettings.authenticationModel="ANONYMOUS"}}}})();(function(){var PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS=20,PROGRESS_JSDO_OP_STRING=["none","create","read","update","delete","submit"],PROGRESS_JSDO_ROW_STATE_STRING=["","created","","modified","deleted"];if(typeof progress==="undefined"){progress={}}if(typeof progress.data==="undefined"){progress.data={}}progress.data._nextid=0;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime());var UID_MAX_VALUE=999999999999999;progress.data._getNextId=function(){var uid=++progress.data._nextid;if(uid>=UID_MAX_VALUE){progress.data._nextid=uid=1;progress.data._uidprefix=""+(Date.now?Date.now():(new Date).getTime())}return progress.data._uidprefix+"-"+uid};var msg={};msg.msgs={};msg.msgs.jsdoMSG000="JSDO, Internal Error: {1}";msg.msgs.jsdoMSG001="JSDO: JSDO has multiple tables. Please use {1} at the table reference level.";msg.msgs.jsdoMSG002="JSDO: Working record for '{1}' is undefined.";msg.msgs.jsdoMSG003="JSDO: {1} function requires a function as a parameter.";msg.msgs.jsdoMSG004="JSDO: Unable to find resource '{1}' in the catalog.";msg.msgs.jsdoMSG005="JSDO: Data for table '{1}' was not specified in addRecords() call.";msg.msgs.jsdoMSG006="JSDO: Data for JSDO was not specified in addRecords() call.";msg.msgs.jsdoMSG007="JSDO: Test function in {1} must return a boolean.";msg.msgs.jsdoMSG008="JSDO: Invalid keyFields parameter in addRecords() call.";msg.msgs.jsdoMSG009="JSDO: KeyField '{1}' in addRecords() call was not found in the schema.";msg.msgs.jsdoMSG010="JSDO: Field '{1}' in relationship was not found in the schema.";msg.msgs.jsdoMSG011="UIHelper: JSDO has multiple tables. "+"Please use {1} at the table reference level.";msg.msgs.jsdoMSG012="UIHelper: Invalid {2} parameter in {1} call.";msg.msgs.jsdoMSG020="JSDO: tableName parameter must be a string in addRecords() call.";msg.msgs.jsdoMSG021="JSDO: addMode parameter must be specified in addRecords() call.";msg.msgs.jsdoMSG022="JSDO: Invalid addMode specified in addRecords() call.";msg.msgs.jsdoMSG023="JSDO: Duplicate found in addRecords() call using APPEND mode.";msg.msgs.jsdoMSG024="{1}: Unexpected signature in call to {2} function.";msg.msgs.jsdoMSG025="{1}: Invalid parameters in call to {2} function.";msg.msgs.jsdoMSG026="JSDO: saveChanges requires a "+"CREATE, UPDATE, DELETE or SUBMIT operation to be defined.";msg.msgs.jsdoMSG030="JSDO: Invalid {1}, expected {2}.";msg.msgs.jsdoMSG031="JSDO: Specified sort field name '{1}' was not found in the schema.";msg.msgs.jsdoMSG032="JSDO: Before-image data already exists for record in addRecords() call.";msg.msgs.jsdoMSG033="{1}: Invalid signature for {2}. {3}";msg.msgs.jsdoMSG034="JSDO: In '{1}' function, JSON data is missing _id";msg.msgs.jsdoMSG035="JSDO: In '{1}' function, before-image JSON data is missing prods:clientId";msg.msgs.jsdoMSG036="JSDO: '{1}' can only be called for a dataset";msg.msgs.jsdoMSG037="{1}: Event name must be provided for {2}.";msg.msgs.jsdoMSG038="Too few arguments. There must be at least {1}.";msg.msgs.jsdoMSG039="The name of the event is not a string.";msg.msgs.jsdoMSG040="The event listener is not a function.";msg.msgs.jsdoMSG041="The event listener scope is not an object.";msg.msgs.jsdoMSG042="'{1}' is not a defined event for this object.";msg.msgs.jsdoMSG043="{1}: A session object was requested to check the status of a Mobile "+"Service named '{2}', but it has not loaded the definition of that service.";msg.msgs.jsdoMSG044="JSDO: In '{1}' function, {2} is missing {3} property.";msg.msgs.jsdoMSG045="JSDO: {1} function: {2} is missing {3} property.";msg.msgs.jsdoMSG046="JSDO: {1} operation is not defined.";msg.msgs.jsdoMSG047="{1} timeout expired.";msg.msgs.jsdoMSG048="{1}: {2} method has argument '{3}' that is missing property '{4}'.";msg.msgs.jsdoMSG049="{1}: Unexpected error calling {2}: {3}";msg.msgs.jsdoMSG050="No token returned from server";msg.msgs.jsdoMSG051="{1} The login method was not executed because the AuthenticationProvider is already logged in.";msg.msgs.jsdoMSG052="{1}: The login method was not executed because no credentials were supplied.";msg.msgs.jsdoMSG053="{1}: {2} was not executed because the AuthenticationProvider is not logged in.";msg.msgs.jsdoMSG054="{1}: Token refresh was not executed because the AuthenticationProvider does not have a refresh token.";msg.msgs.jsdoMSG055="{1}: Token refresh was not executed because the authentication model is not sso.";msg.msgs.jsdoMSG056="{1}: Already logged in.";msg.msgs.jsdoMSG057="{1}: Cannot call {2} when authenticationModel is SSO. Please use the AuthenticationProvider object instead.";msg.msgs.jsdoMSG058="{1}: Cannot pass username and password to addCatalog when authenticationModel "+"is sso. Pass an AuthenticationProvider instead.";msg.msgs.jsdoMSG059="{1}: Error in constructor. The authenticationModels of the "+"AuthenticationProvider ({2}) and the JSDOSession ({3}) were not compatible.";msg.msgs.jsdoMSG060="AuthenticationProvider: AuthenticationProvider is no longer logged in. "+"Tried to refresh SSO token but failed due to authentication error at token server.";msg.msgs.jsdoMSG061="{1}: Attempted to set {2} property to an invalid value.";msg.msgs.jsdoMSG062="{1}: Cannot call {2} when an AuthenticationProvider is already available and logged in.";msg.msgs.jsdoMSG100="JSDO: Unexpected HTTP response. Too many records.";msg.msgs.jsdoMSG101="Network error while executing HTTP request.";msg.msgs.jsdoMSG110="Catalog error: idProperty not specified for resource '{1}'. "+"idProperty is required {2}.";msg.msgs.jsdoMSG111="Catalog error: Schema '{1}' was not found in catalog.";msg.msgs.jsdoMSG112="Catalog error: Output parameter '{1}' was not found for operation '{2}'.";msg.msgs.jsdoMSG113="Catalog error: Found xType '{1}' for output parameter '{2}' "+"for operation '{3}' but xType DATASET, TABLE or ARRAY was expected.";msg.msgs.jsdoMSG114="JSDO: idProperty '{1}' is missing from '{2}' record.";msg.msgs.jsdoMSG115="JSDO: Invalid option specified in {1}() call.";msg.msgs.jsdoMSG116="JSDO: {1} parameter must be a string in {2} call.";msg.msgs.jsdoMSG117="JSDO: Schema from storage area '{1}' does not match JSDO schema";msg.msgs.jsdoMSG118="JSDO: Plugin '{1}' was not found.";msg.msgs.jsdoMSG119="JSDO: A mappingType is expected when 'capabilities' is set."+" Please specify a plugin (ex: JFP).";msg.msgs.jsdoMSG120="JSDO: Parameter '{2}' requires capability '{1}' in the catalog.";msg.msgs.jsdoMSG121="{1}: Argument {2} must be of type {3} in {4} call.";msg.msgs.jsdoMSG122="{1}: Incorrect number of arguments in {2} call. There should be {3}.";msg.msgs.jsdoMSG123="{1}: A server response included an invalid '{2}' header.";msg.msgs.jsdoMSG124="JSDO: autoApplyChanges is not supported for saveChanges(true) "+"with a temp-table. Use jsdo.autoApplyChanges = false.";msg.msgs.jsdoMSG125="{1}: The AuthenticationProvider is not managing valid credentials.";msg.msgs.jsdoMSG126="{1}: No support for {2}.";msg.msgs.jsdoMSG127="JSDO: acceptRowChanges() cannot be called for record with _rejected === true.";msg.msgs.jsdoMSG500="{1}: '{2}' objects must contain a '{3}' property.";msg.msgs.jsdoMSG501="{1}: '{2}' in '{3}' function cannot be an empty string.";msg.msgs.jsdoMSG502="{1}: The '{2}' parameter passed to the '{3}' function has an invalid value for "+"its '{4}' property.";msg.msgs.jsdoMSG503="{1}: '{2}' must be of type '{3}'.";msg.msgs.jsdoMSG504="{1}: {2} has an invalid value for the '{3}' property.";msg.msgs.jsdoMSG505="{1}: '{2}' objects must have a '{3}' method.";msg.msgs.jsdoMSG506="{1}: Invalid argument for the {2} parameter in {3} call.";msg.msgs.jsdoMSG507="{1}: '{2}' is an invalid value for the {3} parameter in {4} call.";msg.msgs.jsdoMSG508="JSDOSession: If a JSDOSession object is using the SSO authentication model, "+"the options object passed to its constructor must include an authProvider property.";msg.msgs.jsdoMSG509="progress.data.getSession: If the authenticationModel is AUTH_TYPE_SSO, "+"authenticationURI and authProviderAuthenticationModel are required parameters.";msg.msgs.jsdoMSG510="{1}: This session has been invalidated and cannot be used.";msg.msgs.jsdoMSG511="JSDOSession: addCatalog() can only be called if an AuthenticationProvider was passed as an argument or "+"connect() has been successfully called.";msg.msgs.jsdoMSG512="JSDOSession: Error while loading multiple catalogs.";msg.msgs.jsdoMSG998="JSDO: JSON object in addRecords() must be DataSet or Temp-Table data.";msg.getMsgText=function(n,args){var text=msg.msgs[n],i;if(!text){throw new Error("Message text was not found by getMsgText()")}for(i=1;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true;data=newDataArray}else{if(params&&(params.sort||params.top)){newDataArray=[];for(i=0;i0){sortObject.tableRef=this;data.sort(this._getCompareFn(sortObject))}}if(params.top){if(typeof params.skip=="undefined"){params.skip=0}data=data.splice(params.skip,params.top)}}return data};this._recToDataObject=function(record,includeChildren){var array=[record];var dataObject=array;if(typeof includeChildren=="undefined"){includeChildren=false}if(this._jsdo._dataSetName){dataObject={};dataObject[this._jsdo._dataSetName]={};dataObject[this._jsdo._dataSetName][this._name]=array;if(includeChildren&&this._children.length>0){var jsrecord=this._findById(record._id,false);if(jsrecord){for(var i=0;i0){for(var j=0;j0){for(var i=0;i=PROGRESS_JSDO_PCT_MAX_EMPTY_BLOCKS)this._needCompaction=true};this._equalRecord=function(rec1,rec2,keyFields){var field;var match=true;for(var i=0;ivalue2||(value1===undefined||value1===null))return sortAscending[i]?1:-1;else if(value10)this._sort(sortObject)}else{this._sort(arg1)}this._createIndex()};this._sort=function(arg1){if(arguments.length===0&&(!this.autoSort||this._sortFn===undefined&&this._sortObject.sortFields===undefined))return;if(arguments.length===0){if(this._sortFn){this._data.sort(this._sortFn)}else{this._data.sort(this._compareFields)}this._needsAutoSorting=false}else{if(typeof arg1=="function"){this._data.sort(this._getCompareFn(arg1))}else{arg1.tableRef=this;this._data.sort(this._getCompareFn(arg1))}if(this.autoSort)this._needsAutoSorting=true}};this.addRecords=function(jsonObject,addMode,keyFields,trackChanges,isInvoke){this._jsdo._addRecords(this._name,jsonObject,addMode,keyFields,trackChanges,isInvoke)};this.acceptChanges=function(){var tableRef=this;for(var id in tableRef._beforeImage){if(tableRef._beforeImage[id]===null){var jsrecord=tableRef._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}else if(this._changed[id]!==undefined){var jsrecord=this._findById(id,false);if(jsrecord!==null){tableRef._jsdo._deleteProdsProperties(jsrecord.data,true)}}}tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[];tableRef._beforeImage={}};this.rejectChanges=function(){for(var id in this._beforeImage){if(this._beforeImage[id]===null){this._jsdo._undoCreate(this,id)}else if(this._changed[id]!==undefined){this._jsdo._undoUpdate(this,id,true)}else{this._jsdo._undoDelete(this,id,true)}}var tableRef=this;tableRef._processed={};tableRef._added=[];tableRef._changed={};tableRef._deleted=[]};this.hasChanges=function(){return Object.keys(this._beforeImage).length!==0};this.getChanges=function(){var result=[];for(var id in this._beforeImage){var item={rowState:"",record:null};if(this._beforeImage[id]===null){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_CREATE];item.record=this._findById(id,false)}else if(this._changed[id]!==undefined){item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_UPDATE];item.record=this._findById(id,false)}else{item.rowState=PROGRESS_JSDO_ROW_STATE_STRING[progress.data.JSDO._OP_DELETE];item.record=new progress.data.JSRecord(this,this._beforeImage[id])}result.push(item)}return result};this._clearErrorStrings=function(){var record=null;for(var id in this._beforeImage){if(this._beforeImage[id]===null){record=this._findById(id,false);if(record){delete record.data._errorString}}else{record=this._findById(id,false);if(record){delete record.data._errorString}else{delete this._beforeImage[id]._errorString}}}};this._applyChanges=function(){var i;for(var id in this._beforeImage){if(this._beforeImage[id]===null){var jsrecord=this._findById(id,false);if(jsrecord===null&&this._jsdo._resource.idProperty!==undefined){if(this._tmpIndex[id]){var record=this._data[this._tmpIndex[id].index];jsrecord=record?new progress.data.JSRecord(this,record):null;delete this._tmpIndex[id]}}if(jsrecord!==null){if(jsrecord.data._rejected||jsrecord.data._errorString!==undefined){this._jsdo._undoCreate(this,id)}else{jsrecord.acceptRowChanges()}}else{var found=false;for(var i=0;i0){for(var i=0;iindex){i--}if(i!=index){this._tableRef._data.splice(index,1);this._tableRef._data.splice(i,0,record);this._tableRef._createIndex()}}}};this.assign=function(record){if(record===undefined)throw new Error(msg.getMsgText("jsdoMSG024","JSDO","assign() or update()"));this._saveBeforeImageUpdate();var fieldName,i,j,value,schema=this._tableRef.getSchema(),prefixElement,name;if(record){for(i=0;i0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){return this.record.data[name][element-1]}}return this.record.data[fieldName]}else return null},set:function(value){var name=fieldName,index,element,fieldInfo;if(this.record){this.record._saveBeforeImageUpdate();try{index=fieldName.indexOf(progress.data.JSDO.ARRAY_INDEX_SEPARATOR);if(index>0&&!this._fields[fieldName.toLowerCase()]){name=fieldName.substring(0,index);element=fieldName.substring(index+progress.data.JSDO.ARRAY_INDEX_SEPARATOR.length);fieldInfo=this._fields[name.toLowerCase()];if(!isNaN(element)&&fieldInfo&&fieldInfo.type==="array"){this.record.data[name][element-1]=value;return}}this.record.data[fieldName]=value}finally{this.record._sortRecord(name)}}},enumerable:true,writeable:true})};Object.defineProperty(this,"hasSubmitOperation",{get:function(){return this._hasSubmitOperation},enumerable:true});Object.defineProperty(this,"hasCUDOperations",{get:function(){return this._hasCUDOperations},enumerable:true});Object.defineProperty(this,"defaultTableRef",{get:function(){return this._defaultTableRef},enumerable:true});this._buffers={};this._numBuffers=0;this._defaultTableRef=null;this._async=true;this._dataProperty=null;this._dataSetName=null;this.operations=[];this.useRelationships=true;this._session=null;this._needCompaction=false;this._hasCUDOperations=false;this._hasSubmitOperation=false;this._useSubmit=false;this.autoApplyChanges=true;this._lastErrors=[];this._localStorage=null;this._convertForServer;this._fillMergeMode;var autoFill=false;if(!arguments[0]){throw new Error("JSDO: Parameters are required in constructor.")}if(typeof arguments[0]=="string"){this.name=arguments[0]}else if(typeof arguments[0]=="object"){var args=arguments[0];for(var v in args){switch(v){case"autoFill":autoFill=args[v];break;case"events":this._events={};for(var eventName in args[v]){this._events[eventName.toLowerCase()]=args[v][eventName]}break;case"dataProperty":this._dataProperty=args[v];break;default:this[v]=args[v]}}}if(!this.name){throw new Error("JSDO: JSDO constructor is missing the value for 'name'")}if(this._events){if(typeof this._events!=="object"){throw new Error("JSDO: JSDO constructor event object is not defined as an object")}for(var prop in this._events){var evt=this._events[prop];if(!(evt instanceof Array)){throw new Error("JSDO: JSDO constructor event object for "+prop+" must be an array")}evt.forEach(function(el){if(typeof el!=="object"){throw new Error("JSDO: JSDO constuctor event object for "+prop+" is not defined as an object")}if(typeof el.fn!=="function"){throw new Error("JSDO: JSDO event listener for "+prop+" is not a function.")}if(el.scope&&typeof el.scope!=="object"){throw new Error("JSDO: JSDO event listener scope for "+prop+" is not an object.")}})}}if(this.name){this._resource=progress.data.ServicesManager.getResource(this.name);if(this._resource){if(!this.url)this.url=this._resource.url;if(!this._dataSetName&&this._resource._dataSetName){this._dataSetName=this._resource._dataSetName;if(this._resource.dataProperty){var buffer=this[this._resource.dataProperty]=new progress.data.JSTableRef(this,this._resource.dataProperty);this._buffers[this._resource.dataProperty]=buffer}else{for(var tableName in this._resource.fields){var buffer=this[tableName]=new progress.data.JSTableRef(this,tableName);this._buffers[tableName]=buffer}}}if(!this._dataProperty&&this._resource.dataProperty)this._dataProperty=this._resource.dataProperty;if(!this._dataSetName){var tableName=this._dataProperty?this._dataProperty:"";this._buffers[tableName]=new progress.data.JSTableRef(this,tableName);if(tableName)this[tableName]=this._buffers[tableName]}var properties,tableName;if(this._dataSetName&&this._resource.schema&&this._resource.schema.properties[this._dataSetName]){properties=this._resource.schema.properties[this._dataSetName].properties;if(Object.keys(properties).length===1){tableName=Object.keys(properties)[0];if(properties[tableName].idProperty){this._resource.idProperty=properties[tableName].idProperty}}}else if(this._resource.schema&&this._resource.schema.properties&&this._resource.schema.properties[tableName]&&this._resource.schema.properties[tableName].idProperty){this._resource.idProperty=this._resource.schema.properties[tableName].idProperty}for(var fnName in this._resource.fn){this[fnName]=this._resource.fn[fnName]["function"]}this._hasCUDOperations=this._resource.generic["create"]!==undefined||this._resource.generic["update"]!==undefined||this._resource.generic["delete"]!==undefined;this._hasSubmitOperation=this._resource.generic["submit"]!==undefined;if(!this._session){var myservice=progress.data.ServicesManager.getService(this._resource.service.name);this._session=myservice._session;this._session._pushJSDOs(this)}}else{throw new Error(msg.getMsgText("jsdoMSG004",this.name))}}else{this._buffers[""]=new progress.data.JSTableRef(this,"")}if(!this._session){throw new Error("JSDO: Unable to get user session for resource '"+this.name+"'")}for(var buf in this._buffers){this._buffers[buf]._parent=null;this._buffers[buf]._children=[];this._buffers[buf]._relationship=null;this._buffers[buf]._isNested=false;if(!this._defaultTableRef)this._defaultTableRef=this._buffers[buf];this._numBuffers++}if(this._numBuffers!=1)this._defaultTableRef=null;else{this.record=null}if(typeof Object.defineProperty=="function"){this._caseSensitive=false;Object.defineProperty(this,"caseSensitive",{get:function(){return this._caseSensitive},set:function(value){this._caseSensitive=value?true:false;for(var buf in this._buffers){this._buffers[buf].caseSensitive=this._caseSensitive}},enumerable:true,writeable:true});this._autoSort=true;Object.defineProperty(this,"autoSort",{get:function(){return this._autoSort},set:function(value){this._autoSort=value?true:false;for(var buf in this._buffers){this._buffers[buf].autoSort=this._autoSort}},enumerable:true,writeable:true})}this._properties={};if(typeof Object.defineProperty=="function"){Object.defineProperty(this,"this._properties",{get:function(){return this._properties},enumerable:false})}if(this._resource&&this._resource.fields){for(var buf in this._buffers){this._buffers[buf]._schema=this._resource.fields[buf];this._buffers[buf]._primaryKeys=this._resource.primaryKeys[buf];this._buffers[buf]._fields={};var fields=this._buffers[buf]._schema;for(var i=0;i1){for(var buf in this._buffers){var fields=[];var found=false;for(var i=0;i=0?index+1:"");element.value=value?value[index]:undefined;return element};this.isDataSet=function(){return this._dataSetName?true:false};this._invokeComplete=function(jsdo,success,request){if(request.async&&request.fnName){jsdo.trigger("afterInvoke",request.fnName,jsdo,success,request)}if(request.deferred){if(success){request.deferred.resolve(jsdo,success,request)}else{request.deferred.reject(jsdo,success,request)}}};this._invokeSuccess=function(){};this._invokeError=function(){};this._httpRequest=function(xhr,method,url,reqBody,request){function afterOpenRequest(){var input=null;if(reqBody){xhr.setRequestHeader("Content-Type","application/json; charset=utf-8");input=JSON.stringify(reqBody)}try{xhr.send(input)}catch(e){request.success=false;request.exception=e;xhr.jsdo._session._checkServiceResponse(xhr,request.success,request)}}if(!xhr){xhr=new XMLHttpRequest;xhr.onCompleteFn=this._invokeComplete;xhr.onSuccessFn=this._invokeSuccess;xhr.onErrorFn=this._invokeError;xhr.onreadystatechange=this.onReadyStateChangeGeneric;if(request.async&&request.fnName){this.trigger("beforeInvoke",request.fnName,this,request)}if(reqBody){if(this._resource&&this._resource.service){var useRequest=this._resource.service.useRequest;if(this._resource.service.settings&&this._resource.service.settings.useRequest!==undefined){useRequest=this._resource.service.settings.useRequest}if(useRequest){reqBody={request:reqBody}}}}}xhr.request=request;xhr.jsdo=this;request.jsdo=this;request.xhr=xhr;this._session._openRequest(xhr,method,url,request.async,afterOpenRequest);return request};this._getDataObject=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};var oldUseRelationships=this.useRelationships;try{this.useRelationships=false;for(var buf in this._buffers){dataObject[this._dataSetName][buf]=this._buffers[buf].getData()}}finally{this.useRelationships=oldUseRelationships}}else{if(this._dataProperty){dataObject[this._dataProperty]=this.getData()}else return this.getData()}return dataObject};this._getDataObjectAsNested=function(){var dataObject={};if(this._dataSetName){dataObject[this._dataSetName]={};try{for(var buf in this._buffers){var bufObj=this._buffers[buf];if(bufObj._isNested)continue;this._nestChildren=false;if(bufObj._children.length>0){for(var i=0;i0){hasErrors=true}}if(hasErrors){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._allRecordsRejected=true;this._someRecordsRejected=false;hasCommittedRecords=false;for(i=0;i0&&!param.operations[0].success){this._allRecordsRejected=true;this._someRecordsRejected=true;for(i=0;i0){this._convertForServer=true;this._buffers[buf]._convertForServer=true}}};this._convertRequestData=function(objParam){var buf,beforeData;if(this._convertForServer===false){return}for(buf in this._buffers){if(this._buffers[buf]._convertForServer){if(objParam[this._dataSetName]){if(objParam[this._dataSetName][buf]){this._convertTableData(this._buffers[buf],objParam[this._dataSetName][buf])}beforeData=objParam[this._dataSetName]["prods:before"];if(beforeData&&beforeData[buf]){this._convertTableData(this._buffers[buf],beforeData[buf])}}else if(objParam[buf]){this._convertTableData(this._buffers[buf],objParam[buf])}}}};this._convertTableData=function(tableRef,tableData){var i;for(i=0;i0){this._confirmOperationExists(progress.data.JSDO._OP_DELETE);checkedDelete=true}if(!checkedCreate&&tableRef._added.length>0){this._confirmOperationExists(progress.data.JSDO._OP_CREATE);checkedCreate=true}if(!checkedUpdate&&Object.keys(tableRef._changed).length>0){this._confirmOperationExists(progress.data.JSDO._OP_UPDATE);checkedUpdate=true}if(checkedDelete&&checkedCreate&&checkedUpdate){break}}};this._confirmOperationExists=function(operation){var operationStr=PROGRESS_JSDO_OP_STRING[operation];if(typeof this._resource.generic[operationStr]!=="function"){throw new Error(msg.getMsgText("jsdoMSG046",operationStr.toUpperCase()))}};this.invoke=function(name,object){var deferred,promise;try{var request=this[name](object);if(request.deferred){deferred=request.deferred;promise=request.deferred.promise()}}catch(error){if(progress.util.Deferred.useJQueryPromises){throw error}else{if(!deferred){deferred=new progress.util.Deferred;promise=deferred.promise()}deferred.reject(this,false,{errorObject:error})}}return promise};this._syncTableRef=function(operation,tableRef,batch){var rowData,requestData,jsonObject,dataSetObject;if(tableRef._visited)return;tableRef._visited=true;if(!batch){batch={operations:[]}}else if(!batch.operations){batch.operations=[]}switch(operation){case progress.data.JSDO._OP_CREATE:for(var i=0;i0&&!dataSetJsonObject[tableRef._name])dataSetJsonObject[tableRef._name]=[];for(var i=0;i0||tableRef._added.length>0||hasUpdates){hasChanges=true;break}}return hasChanges};this._addDeletesToChangeSet=function(tableRef,dataSetJsonObject,request){for(var i=0;i=10){tmpIndex={};for(var i=0;ivalue2||value1===null)return false;else if(value11){for(var buf in this._buffers){if(this._buffers[buf]._isNested&&this._buffers[buf]._parent&&this._buffers[this._buffers[buf]._parent]){var srcData=this._buffers[this._buffers[buf]._parent]._data;var data=[];for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}for(var i=0;i1){xhr.request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}var recordId=beforeTableJsonObject[0]["prods:clientId"];if(!recordId){throw new Error(msg.getMsgText("jsdoMSG035","_checkForDeleteError()"))}if(beforeTableJsonObject[0]["prods:hasErrors"]){var prods_id=beforeTableJsonObject[0]["prods:id"];var errorString=this._getErrorStringFromJsonObject(dataSetJsonObject,tableRef,prods_id);this._setErrorString(tableRef,recordId,errorString,true);hasError=true}}return hasError};this._mergeUpdateForSubmit=function(jsonObject,xhr){var errorString;if(!this._dataSetName){throw new Error(msg.getMsgText("jsdoMSG036","_mergeUpdateForSubmit()"))}var dataSetJsonObject=jsonObject[this._dataSetName];if(dataSetJsonObject[this._dataSetName])dataSetJsonObject=dataSetJsonObject[this._dataSetName];var beforeJsonObject=dataSetJsonObject["prods:before"];for(var buf in this._buffers){var tableRef=this._buffers[buf];var tableJsonObject=dataSetJsonObject[tableRef._name];if(tableJsonObject instanceof Array){for(var i=0;i1){request.success=false;throw new Error(msg.getMsgText("jsdoMSG100"))}}if(beforeJsonObject){hasError=jsdo._checkForDeleteError(dataSetJsonObject,xhr)}if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._deleteError(jsdo,success,request)}}};this._deleteError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoDelete(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._createComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterCreate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterCreate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._createSuccess=function(jsdo,success,request){var xhr=request.xhr;var record=request.response;var hasError=jsdo._mergeUpdateForCUD(record,xhr);if(hasError)request.success=false;if(jsdo.autoApplyChanges){if(!hasError){delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._createError(jsdo,success,request)}}};this._createError=function(jsdo,success,request){if(jsdo.autoApplyChanges){jsdo._undoCreate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._updateComplete=function(jsdo,success,request){var xhr=request.xhr;var jsrecord=request.jsrecord;try{jsdo._deleteProdsProperties(jsrecord.data,false);jsrecord._tableRef.trigger("afterUpdate",jsdo,jsrecord,request.success,request);jsdo.trigger("afterUpdate",jsdo,jsrecord,request.success,request)}finally{request.complete=true;jsdo._checkSaveComplete(xhr)}};this._updateSuccess=function(jsdo,success,request){var xhr=request.xhr;var hasError=jsdo._mergeUpdateForCUD(request.response,xhr);if(hasError){request.success=false}if(jsdo.autoApplyChanges){if(!hasError){request.success=true;delete request.jsrecord._tableRef._beforeImage[request.jsrecord.data._id]}else{jsdo._updateError(jsdo,success,request)}}};this._updateError=function(jsdo,success,request){if(jsdo.autoApplyChanges){request.success=false;jsdo._undoUpdate(request.jsrecord._tableRef,request.jsrecord.data._id)}};this._saveChangesSuccess=function(jsdo,success,request){var records=request.response;jsdo._mergeUpdateForSubmit(records,request.xhr);jsdo._clearErrors();var changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(changes);if(jsdo.autoApplyChanges){jsdo._applyChanges()}};this._saveChangesError=function(jsdo,success,request){jsdo._setAllRecordsRejected(true);if(jsdo.autoApplyChanges){jsdo.rejectChanges()}jsdo._updateLastErrors(jsdo,null,null,request)};this._saveChangesSuccessTT=function(jsdo,success,request){var changes;jsdo._clearErrors();changes=jsdo.getChanges();jsdo._updateLastErrors(jsdo,null,changes);jsdo._setAllRecordsRejected(false)};this._saveChangesComplete=function(jsdo,success,request){if(request.xhr.status>=200&&request.xhr.status<300&&(jsdo._lastErrors.length>0||jsdo._someRecordsRejected)){request.success=false}if(jsdo._useSubmit===true){jsdo._fireCUDTriggersForSubmit(request)}jsdo._undefWorkingRecord();jsdo._fireAfterSaveChanges(request.success,request)};this._fireAfterSaveChanges=function(success,request){this.trigger("afterSaveChanges",this,success,request);if(request.jsrecords){if(request.deferred){if(success){request.deferred.resolve(this,success,request)}else{request.deferred.reject(this,success,request)}}}else if(request.batch&&request.batch.deferred){if(success){request.batch.deferred.resolve(this,success,request)}else{request.batch.deferred.reject(this,success,request)}}var clearErrorString=this.autoApplyChanges;if(request.jsrecords){for(var idx=0;idx=400&&request.xhr.status<600){try{var responseObject=JSON.parse(request.xhr.responseText);if(responseObject instanceof Array){errorArray=responseObject}else if(responseObject instanceof Object){errorArray.push(responseObject)}for(i=0;i=400&&request.xhr.status<600)){errors.push({type:progress.data.JSDO.ERROR,error:"Error: HTTP Status "+request.xhr.status+" "+request.xhr.statusText,responseText:request.xhr.responseText})}}return errors};this._updateLastErrors=function(jsdo,batch,changes,request){var errors,errorText,responseObject,i,j,buf;if(batch){if(batch.operations===undefined)return;for(i=0;i=200&&request.xhr.status<300){jsdo._lastErrors.push({errorString:request.jsrecord.data._errorString});jsdo._buffers[request.jsrecord._tableRef._name]._lastErrors.push({type:progress.data.JSDO.DATA_ERROR,id:request.jsrecord.data._id,error:request.jsrecord.data._errorString})}else{errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}if(request.jsrecord&&(errors[j].type===progress.data.JSDO.APP_ERROR||errors[j].type===progress.data.JSDO.RETVAL)){errors[j].id=request.jsrecord.data._id;request.jsrecord._tableRef._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}}}}else if(changes instanceof Array){for(i=0;i=400&&request.xhr.status<600||request.xhr.status===0)){errors=this._getErrorsFromRequest(request);errorText="";for(j=0;j1&&errors[j].error.indexOf("(7243)")!=-1){continue}for(buf in this._buffers){this._buffers[buf]._lastErrors.push(errors[j])}if(errorText.length===0){errorText=errors[j].error}else{errorText+="\n"+errors[j].error}}jsdo._lastErrors.push({errorString:errorText})}};this._checkSaveComplete=function(xhr){if(xhr.request){var jsdo=xhr.request.jsdo;var batch=xhr.request.batch;if(jsdo&&batch&&jsdo._async){if(jsdo._isBatchComplete(batch)){var success=jsdo._isBatchSuccess(batch);var request={batch:batch,success:success};jsdo._undefWorkingRecord();jsdo._lastErrors=[];if(!success&&batch.operations){jsdo._updateLastErrors(jsdo,batch,null)}this._setAllRecordsRejected(batch);jsdo._fireAfterSaveChanges(success,request)}}}};this._isBatchSuccess=function(batch){if(batch.operations){for(var i=0;i=200&&xhr.status<300||xhr.status===0&&xhr.responseText!==""){request.success=true;xhr.jsdo._session._saveClientContextId(xhr);if(typeof xhr.onSuccessFn=="function"){var operation;if(xhr.request.fnName!==undefined&&xhr.jsdo._resource.fn[xhr.request.fnName]!==undefined){operation=xhr.jsdo._resource.fn[xhr.request.fnName].operation}else operation=null;if(operation===undefined||operation!==null&&operation.mergeMode)xhr.jsdo._mergeInvoke(request.response,xhr);if(request.success)xhr.onSuccessFn(xhr.jsdo,request.success,request);else if(typeof xhr.onErrorFn=="function")xhr.onErrorFn(xhr.jsdo,request.success,request)}}else{request.success=false;if(xhr.status===0){request.exception=new Error(msg.getMsgText("jsdoMSG101"))}if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}}catch(e){request.success=false;request.exception=e;if(typeof xhr.onErrorFn=="function"){xhr.onErrorFn(xhr.jsdo,request.success,request)}}xhr.jsdo._session._checkServiceResponse(xhr,request.success,request);if(typeof xhr.onCompleteFn=="function"){xhr.onCompleteFn(xhr.jsdo,request.success,request)}}};this.acceptChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].acceptChanges()}};this.rejectChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name].rejectChanges()}};this.getChanges=function(){var result=[];for(var buf in this._buffers){var changes=this._buffers[this._buffers[buf]._name].getChanges();result=result.concat(changes)}return result};this.hasChanges=function(){for(var buf in this._buffers){if(this._buffers[this._buffers[buf]._name].hasChanges())return true}return false};this._applyChanges=function(){for(var buf in this._buffers){this._buffers[this._buffers[buf]._name]._applyChanges()}};this.acceptRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.acceptRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","acceptRowChanges()"))};this.rejectRowChanges=function(){if(this._defaultTableRef)return this._defaultTableRef.rejectRowChanges();throw new Error(msg.getMsgText("jsdoMSG001","rejectRowChanges()"))};this.setProperties=function(propertiesObject){var prop;if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperties",1))}if(typeof propertiesObject=="object"){this._properties={};for(prop in propertiesObject){if(propertiesObject.hasOwnProperty(prop)){if(typeof propertiesObject[prop]!=="function"){this._properties[prop]=propertiesObject[prop]}}}}else if(propertiesObject===undefined||propertiesObject===null){this._properties={}}else{throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"Object","setProperties"))}};this.setProperty=function(propertyName,propertyValue){if(arguments.length<2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(arguments.length!==2){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","setProperty",2))}if(typeof propertyName!=="string"){throw new Error(progress.data._getMsgText("jsdoMSG121","JSDO",1,"string","setProperty"))}if(propertyValue===undefined){delete this._properties[propertyName]}else{this._properties[propertyName]=propertyValue}};this.getProperties=function(){if(arguments.length>0){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperties",0))}return this._properties};this.getProperty=function(propertyName){if(arguments.length<1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}if(arguments.length>1){throw new Error(progress.data._getMsgText("jsdoMSG122","JSDO","getProperty",1))}return this._properties[propertyName]};this.saveLocal=function saveLocal(arg1,arg2){var name;var dataMode;if(arguments.length>2){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"||arg1===null||arg1===undefined){name=arg1;dataMode=arg2}else{name=null;dataMode=arg1}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}if(typeof dataMode=="undefined"){dataMode=progress.data.JSDO.ALL_DATA}else{switch(dataMode){case progress.data.JSDO.ALL_DATA:case progress.data.JSDO.CHANGES_ONLY:break;default:throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var dataObj=this._prepareDataObjectForLocalStorage(dataMode);this._localStorage.saveToLocalStorage(name,dataObj)};this.readLocal=function readLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));this._restoreFromLocalStorage(object,progress.data.JSDO.MODE_EMPTY)}return object!==null};this.addLocalRecords=function addLocalRecords(arg1,arg2,arg3){var name;var addMode;var keyFields;if(arguments.length<1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(typeof arg1=="string"){name=arg1;addMode=arg2;keyFields=arg3}else{name="jsdo_"+this._resource.service.name+"_"+this._resource.name;addMode=arg1;keyFields=arg2}if(typeof name=="undefined"||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(addMode!=progress.data.JSDO.MODE_REPLACE){throw new Error(msg.getMsgText("jsdoMSG115",arguments.callee.name))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}var object=this._localStorage.readFromLocalStorage(name);if(object){if(this._hasMatchingSchema(object)===false)throw new Error(msg.getMsgText("jsdoMSG117",name));try{this._restoreFromLocalStorage(object,addMode,keyFields)}catch(e){var text=e.message;throw new Error(text.replace(new RegExp("addRecords","g"),"addLocalRecords"))}}return object!==null};this._containsPrimaryKeys=function _containsPrimaryKeys(){for(var buf in this._buffers){if(this._buffers[buf]._primaryKeys===null)return false}return true};this._hasMatchingSchema=function _hasMatchingSchema(storageObject){var isValid=true;if(storageObject===null||Object.keys(storageObject).length===0)return true;if(this._dataSetName){if(storageObject[this._dataSetName]){for(var buf in this._buffers)if(storageObject[this._dataSetName][buf]===undefined){isValid=false;break}}else isValid=false}else if(this._dataProperty){storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._dataProperty]===undefined)isValid=false}else{storageObject=storageObject["_localStorage"];if(storageObject===undefined||storageObject[this._defaultTableRef._name]===undefined)isValid=false}return isValid};this.deleteLocal=function deleteLocal(name){if(arguments.length>1){throw new Error(msg.getMsgText("jsdoMSG024","JSDO",arguments.callee.name+"()"))}if(name===undefined||name===null||name===""){name="jsdo_"+this._resource.service.name+"_"+this._resource.name}else if(typeof name!="string"){throw new Error(msg.getMsgText("jsdoMSG116","name",arguments.callee.name+"()"))}if(this._localStorage===null){this._localStorage=new progress.data.LocalStorage}this._localStorage.clearLocalStorage(name)};this._prepareDataObjectForLocalStorage=function(option){var storageObject={};if(this._dataSetName){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet(this._dataSetName);break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet(this._dataSetName,true);break}}else if(this._dataProperty){switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}else{switch(option){case progress.data.JSDO.ALL_DATA:storageObject=this._createDataAndChangeSet("_localStorage");break;case progress.data.JSDO.CHANGES_ONLY:storageObject=this._createChangeSet("_localStorage",true);break}}return storageObject};this._restoreFromLocalStorage=function(storageObject,addMode,keyFields){if(storageObject&&Object.keys(storageObject).length>0){if(this._dataSetName){for(var buf in this._buffers)this._restoreDataForTable(this._buffers[buf],storageObject,addMode,keyFields)}else this._restoreDataForTable(this._defaultTableRef,storageObject,addMode,keyFields)}else if(addMode===progress.data.JSDO.MODE_EMPTY)this._clearData()};this._restoreDataForTable=function(tableRef,jsonObject,addMode,keyFields){keyFields=keyFields!==undefined?keyFields:tableRef._primaryKeys;if(keyFields===undefined&&this._resource.idProperty){keyFields=[];keyFields[0]=this._resource.idProperty}if(this._dataSetName){var oldUseRelationships=this.useRelationships;this.useRelationships=false;try{tableRef.addRecords(jsonObject,addMode,keyFields)}finally{this.useRelationships=oldUseRelationships}}else{this._dataSetName="_localStorage";tableRef.addRecords(jsonObject,addMode,keyFields);this._dataSetName=null}};this.getMethodProperties=function(operation,name){var idx;if(this._resource._operations){if(this._resource._operations[operation]){return this._resource._operations[operation]}}else{this._resource._operations={}}for(var idx=0;idx1?[params.sort]:[]}sortFields="";for(index=0;index=1?params.filter:undefined}if(params.filter){if(typeof params.filter==="string"){doConversion=false}params.tableRef=tableName;if(doConversion&¶ms.tableRef===undefined){throw new Error(msg.getMsgText("jsdoMSG045","fill() or read()","params","tableRef"))}if(reqCapabilities["filter"].mapping==="ablFilter"){if(doConversion){ablFilter=progress.util._convertToABLWhereString(jsdo._buffers[params.tableRef],params.filter)}else{ablFilter=params.filter}}else if(reqCapabilities["filter"].mapping==="sqlQuery"){if(doConversion){sqlQuery=progress.util._convertToSQLQueryString(jsdo._buffers[params.tableRef],params.filter,true)}else{sqlQuery=params.filter}}}filter=JSON.stringify({ablFilter:ablFilter,sqlQuery:sqlQuery,orderBy:sortFields,skip:params.skip,top:params.top,id:params.id});params={filter:filter}}return params}});if(typeof progress.ui=="undefined")progress.ui={};progress.ui.UITableRef=function UITableRef(tableRef){this._tableRef=tableRef;this._listview=null;this._detailPage=null;this._listviewContent=undefined;this.addItem=function(format){var detailForm;if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._name));if(!this._listview)return;format=format?format:this._listview.format;detailForm=this._detailPage&&this._detailPage.name?this._detailPage.name:"";if(this._listviewContent===undefined){this.clearItems()}var text=this._listview.itemTemplate?this._listview.itemTemplate:progress.ui.UIHelper._itemTemplate;text=text.replace(new RegExp("{__format__}","g"),format);text=text.replace(new RegExp("{__id__}","g"),this._tableRef.record.data._id);text=text.replace(new RegExp("{__page__}","g"),detailForm);for(var field in this._tableRef.record.data){var value=this._tableRef.record.data[field];text=text.replace(new RegExp("{"+field+"}","g"),value!==undefined&&value!==null?value:"")}this._listviewContent+=text};this.clearItems=function(){if(this._listview){this._listviewContent="";var listviewElement=document.getElementById(this._listview.name);if(listviewElement){listviewElement.innerHTML=""}}};this._getFormFieldValue=function(fieldName,detailPageName){var value=null,field;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)value=field.val()}else{field=document.getElementById(fieldName);if(field){value=field.value}}return value};this._setFormField=function(fieldName,value,detailPageName){var field=null;if(detailPageName===undefined){if(this._detailPage&&this._detailPage.name)detailPageName=this._detailPage.name}if(typeof $=="function"&&detailPageName){field=$("#"+detailPageName+" #"+fieldName);if(!field||field.length===0)field=$("#"+detailPageName+' [dsid="'+fieldName+'"]');if(field&&field.length==1)field.val(value)}else{field=document.getElementById(fieldName);if(field){field.value=value}}};this.assign=function(detailPageName){if(!this._tableRef.record)throw new Error(msg.getMsgText("jsdoMSG002",this._tableRef._name));if(arguments.length!==0&&typeof detailPageName!="string")throw new Error(msg.getMsgText("jsdoMSG024","UIHelper","assign()"));this._tableRef.record.assign(null);var fieldName;var schema=this._tableRef.getSchema();for(var i=0;i0){for(var i=0;i'}else htmltext="";htmltext+='";fields=null;return htmltext};this.getListViewRecord=function(htmlIElement){var id=htmlIElement.getAttribute("data-id");return this._tableRef.findById(id)};this.getFormRecord=function(detailPageName){var id=this._getFormFieldValue("_id",detailPageName);return this._tableRef.findById(id)};this._getIdOfElement=function(name){if(typeof $=="function"){var element=$("#"+name);if(!element||element.length===0){element=$('[dsid="'+name+'"]');if(element&&element.length==1){var id=element.attr("id");if(id)return id}}}return name};this.setDetailPage=function setDetailPage(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));this._detailPage=obj;this._detailPage.name=this._getIdOfElement(this._detailPage.name)};this.setListView=function setListView(obj){if(!obj||typeof obj!="object")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"object"));if(!obj.name||typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"name"));if(obj.format&&typeof obj.name!="string")throw new Error(msg.getMsgText("jsdoMSG012",arguments.callee.name,"format"));this._listview=obj;this._listview.name=this._getIdOfElement(this._listview.name);if(!this._listview.format){if(typeof $=="function"){for(var i=0;i'+'{__format__}';progress.ui.UIHelper._defaultFieldTemplate='