text: define(["require","dataSource/model/JdbcDataSourceModel","dataSource/model/BaseDataSourceModel","dataSource/collection/JdbcDriverCollection","settings!dataSourcePatterns","dataSource/enum/connectionTypes","bi/repository/enum/repositoryResourceTypes","underscore","jquery","bundle!jasperserver_messages","settings!awsSettings","bundle!jasperserver_config","dataSource/util/settingsUtility"],function(e){"use strict";var t=e("dataSource/model/JdbcDataSourceModel"),r=e("dataSource/model/BaseDataSourceModel"),i=e("dataSource/collection/JdbcDriverCollection"),a=e("settings!dataSourcePatterns"),s=e("dataSource/enum/connectionTypes"),n=e("bi/repository/enum/repositoryResourceTypes"),o=e("underscore"),c=e("jquery"),d=e("bundle!jasperserver_messages"),l=e("settings!awsSettings"),u=e("bundle!jasperserver_config"),p=e("dataSource/util/settingsUtility"),g=t.extend({otherDriverIsPresent:!1,type:n.AWS_DATA_SOURCE,defaults:function(){var e={};return o.extend(e,t.prototype.defaults,{dbName:"",dbInstanceIdentifier:"",dbService:"",accessKey:"",secretKey:"",roleArn:"",region:"",credentialsType:"",connectionType:s.AWS}),e}(),validation:function(){var e={};return o.extend(e,{connectionUrl:[{required:!0,msg:d["ReportDataSourceValidator.error.not.empty.reportDataSource.connectionUrl"]},{xRegExpPattern:XRegExp(a.forbidWhitespacesPattern),msg:d["ReportDataSourceValidator.error.invalid.chars.reportDataSource.connectionUrl"]}],username:[{required:!0,msg:d["ReportDataSourceValidator.error.not.empty.reportDataSource.username"]}],driverClass:[{required:!0,msg:d["ReportDataSourceValidator.error.not.empty.reportDataSource.driverClass"]},{xRegExpPattern:XRegExp(a.forbidWhitespacesPattern),msg:d["ReportDataSourceValidator.error.invalid.chars.reportDataSource.driverClass"]},{fn:function(e,t,r){var i=new RegExp(a.attributePlaceholderPattern).test(e);if(!i){var s=this.drivers.getDriverByClass(e);if(!s||!s.get("available"))return d["ReportDataSourceValidator.error.not.empty.reportDataSource.driverNotInstalled"]}}}],dbName:[{required:!0,msg:d["ReportDataSourceValidator.error.not.empty.reportDataSource.dbNameIsEmpty"]}],region:[{required:!0}],accessKey:[{fn:function(e,t,r){return r.credentialsType===g.credentialsType.AWS&&(o.isNull(e)||o.isUndefined(e)||o.isString(e)&&""===e)?d["fillParameters.error.mandatoryField"]:void 0}}],secretKey:[{fn:function(e,t,r){return r.credentialsType===g.credentialsType.AWS&&(o.isNull(e)||o.isUndefined(e)||o.isString(e)&&""===e)?d["fillParameters.error.mandatoryField"]:void 0}}]}),e}(),initialize:function(e,t){r.prototype.initialize.apply(this,arguments);var a=p.deepDefaults(t,{awsSettings:l});this.isNew()?this.set("region",o.first(a.awsSettings.awsRegions)):(this.set("password",u["input.password.substitution"]),this.set("secretKey",u["input.password.substitution"])),this.set("credentialsType",!a.awsSettings.isEc2Instance||a.awsSettings.suppressEc2CredentialsWarnings||""!==this.get("accessKey")?g.credentialsType.AWS:g.credentialsType.EC2),this.initialization=c.Deferred(),this.drivers=new i([],this.options);var s=this;this.drivers.fetch({reset:!0}).done(function(){s.initialization.resolve()}),this.on("change:dbName change:dbPort change:dbHost change:sName change:connectionUrlTemplate",this.updateConnectionUrl),this.on("change:credentialsType",this.changeCredentialsType)},updateConnectionUrl:function(){if(this.get("connectionUrlTemplate")){var e=this.pick(["dbName","dbPort","dbHost","sName"]);e.sName||(e.sName=e.dbName);var t=this.replaceConnectionUrlTemplatePlaceholdersWithValues(this.get("connectionUrlTemplate"),e);this.set("connectionUrl",t)}},changeCredentialsType:function(){var e=this.get("credentialsType")===g.credentialsType.EC2;e&&this.set({accessKey:"",secretKey:"",roleArn:""})},toJSON:function(){var e=t.prototype.toJSON.apply(this,arguments);return this.options.isEditMode&&e.secretKey===u["input.password.substitution"]&&(e.secretKey=null),e},getFullDbTreePath:function(){return this.get("dbInstanceIdentifier")&&this.get("dbService")?"/"+this.get("dbService")+"/"+this.get("dbInstanceIdentifier"):null}},{credentialsType:{EC2:"ec2",AWS:"aws"}});return g});