UNPKG

graphdb-workbench

Version:
2 lines 9.73 kB
export const __webpack_esm_id__=14824;export const __webpack_esm_ids__=[12098,14824,44207,47775,54159,64803,94003];export const __webpack_esm_modules__={12098(e,t,r){r.d(t,{s:()=>o});const o={GENERIC:"generic",MY_SQL:"mySQL",POSTGRESS:"postgreSQL",ORACLE:"oracle",MS_SQL:"msSQL",DB2:"DB2",DREMIO:"dremio",DATABRICKS:"databricks",SNOWFLAKE:"snowflake"}},14824(e,t,r){var o=r(46591),a=r(64803),n=r(54159),i=r(44207),s=r(94003),l=r(47775),p=r(12098);const c=r(304).I.logger;function d(e,t,r,d,m){return{restrict:"E",scope:!1,templateUrl:"js/angular/repositories/templates/ontop-repo.html",link:function(f){f.isGenericDriver=!0,f.defaultUrlTemplate="jdbc:database://localhost:port/database_name",f.ontopProperiesLink="https://ontop-vkg.org/guide/advanced/configuration.html",f.ontopFileType=a.x,f.selectedDriver=new l.t,f.supportedDriversData=[],f.formData={connectionInformation:new n.L,settings:{additionalProperties:"",ontopFiles:[]}},f.selectDriver=e=>{f.selectedDriver=f.supportedDriversData.find(t=>t.driverType===e),f.isGenericDriver=l.t.isGenericDriver(f.selectedDriver.driverType),f.editRepoPage&&f.currentOntopRepoInfo&&f.currentOntopRepoInfo.connectionInformation.driverType===e?f.formData=_.cloneDeep(f.currentOntopRepoInfo):(R(),f.formData.connectionInformation.driverType=f.selectedDriver.driverType),f.formData.connectionInformation.driverClass=f.selectedDriver.driverClass,f.updateUrl()},f.getOntopFileInfo=e=>f.formData.settings.ontopFiles.find(t=>e===t.type),f.getHostNameLabel=()=>{const e=l.t.isSnowflakeDriver(f.selectedDriver.driverType)?"ontop.repo.database.snowflake.host_name":"ontop.repo.database.host_name";return m.instant(e)+"*"},f.getDatabaseNameLabel=()=>{let e="";switch(f.selectedDriver.driverType){case p.s.SNOWFLAKE:e="ontop.repo.database.warehouse.database_name";break;case p.s.DATABRICKS:e="ontop.repo.database.http_path.database_name";break;case p.s.DREMIO:e="ontop.repo.database.schema.database_name";break;default:e="ontop.repo.database.database_name"}return m.instant(e)},f.updateUrl=()=>{const e=v()||"";f.formData.connectionInformation.url=e+f.formData.connectionInformation.urlUserInput},f.isTestConnectionDisabled=()=>{const e=f.formData.connectionInformation,t=f.selectedDriver;return!(e.driverClass&&e.url&&(!t.portRequired||e.port)&&(l.t.isGenericDriver(t.driverType)||e.hostName&&e.databaseName))},f.testConnection=()=>{b().then(F).then(N).then(T).then(w).then(g).then(()=>t.validateOntopPropertiesConnection(f.repositoryInfo)).then(()=>r.success(m.instant("ontop.repo.successful.connection.msg"))).catch(e=>{e instanceof s.L?r.error(e.message):y(m.instant("ontop.repo.failed.to.connect"),e)})},f.editFile=r=>{const a=f.repositoryInfo.params[r.type].label,n=m.instant("update.file.edit.content.header",{fileName:a});e.open({templateUrl:"js/angular/templates/modal/editRepoFile.html",controller:"EditRepositoryFileCtrl",windowClass:"update-ontop-repo-dialog",resolve:{file:()=>{const e=f.repositoryInfo.params[r.type];return e?e.value:""},dialogTitle:()=>n,location:()=>f.repositoryInfo.location}}).result.then(e=>{t.updateRepositoryFileContent(e.fileLocation,e.content,f.repositoryInfo.location).success(e=>{r.fileName=(0,o.W)(e.fileLocation),f.repositoryInfo.params[r.type].value=e.fileLocation}).error(e=>{y(m.instant("common.error"),e)})})},f.uploadOntopFile=(e,t)=>{if(e&&e.length){const o=e[0];t.loading=!0;const a={url:"rest/repositories/file/upload",data:{file:o,location:f.repositoryInfo.location}};d.upload(a).success(e=>{e.success?(t.fileName=o.name,f.repositoryInfo.params[t.type].value=e.fileLocation):r.error(e.errorMessage)}).error(e=>{y(m.instant("common.error"),e),f.uploadFile=""}).finally(()=>{t.loading=!1})}},f.updateOntopRepo=()=>{const e=f.editRepoPage?f.editRepository:f.createRepo;L().then(b).then(F).then(N).then(T).then(w).then(P).then(g).then(e).catch(e=>{e instanceof s.L?r.error(e.message):c.info(e)})},f.onKeyDownInUrlInput=e=>{const t=e.keyCode;if(37===t||39===t||36===t||35===t)return;const r=v();if(!r)return;const o=e.ctrlKey||e.metaKey;if(o&&65===t||o&&67===t)return;const a=e.target.selectionStart;8===t&&a-1<r.length&&(e.preventDefault(),e.stopPropagation()),a<r.length&&(e.preventDefault(),e.stopPropagation())},f.onKeyUpInUrlInput=()=>{u()};const u=()=>{const e=v();e&&f.formData.connectionInformation.url.startsWith(e)?f.formData.connectionInformation.urlUserInput=f.formData.connectionInformation.url.substring(e.length):f.formData.connectionInformation.urlUserInput=f.formData.connectionInformation.url},v=()=>l.t.isSnowflakeDriver(f.selectedDriver.driverType)?D():h(),D=()=>{let e=f.selectedDriver.urlTemplate;const t=f.formData.connectionInformation;return t.hostName&&(e=e.replace("{identifier}",t.hostName)),t.port&&(e=e.replace(".snowflakecomputing.com/?",`.snowflakecomputing.com:${t.port}/?`)),t.databaseName&&(e=e.replace("{database}",t.databaseName)),e},h=()=>{let e=f.selectedDriver.urlTemplate;const t=f.formData.connectionInformation;return t.hostName&&(e=t.port?e.replace("{hostport}",`${t.hostName}:${t.port}`):e.replace("{hostport}",`${t.hostName}`)),t.databaseName&&(e=e.replace("{database}",t.databaseName)),e},I=e=>{f.formData.settings.ontopFiles.forEach(t=>{t.loading=e})},g=()=>{I(!0);const e=f.formData.connectionInformation,r={hostName:e.hostName,port:e.port,databaseName:e.databaseName,userName:e.username,password:e.password,driverClass:e.driverClass,url:e.url,additionalProperties:f.formData.settings.additionalProperties};return t.updatePropertiesFile(f.repositoryInfo.params.propertiesFile.value,r,f.repositoryInfo.location,f.selectedDriver.driverType).success(e=>{f.repositoryInfo.params.propertiesFile.value=e.fileLocation}).error(e=>{y(m.instant("common.error"),e)}).finally(()=>I(!1))},y=(e,t)=>{const o=getError(t);r.error(o,e)},b=()=>l.t.isGenericDriver(f.selectedDriver.driverType)||f.formData.connectionInformation.hostName?Promise.resolve():Promise.reject(new s.L(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.host_name")}))),N=()=>l.t.isGenericDriver(f.selectedDriver.driverType)||f.formData.connectionInformation.databaseName?Promise.resolve():Promise.reject(new s.L(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.database_name")}))),T=()=>f.formData.connectionInformation.driverClass?Promise.resolve():Promise.reject(new s.L(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.driver_class")}))),w=()=>f.formData.connectionInformation.url?Promise.resolve():Promise.reject(new s.L(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.url")}))),L=()=>f.repositoryInfo.id?Promise.resolve():Promise.reject(new s.L(m.instant("empty.repoid.warning"))),P=()=>f.getOntopFileInfo(a.x.OBDA).fileName?Promise.resolve():Promise.reject(new s.L(m.instant("ontop.repo.missing.required.file",{fileName:f.repositoryInfo.params[a.x.OBDA].label}))),F=()=>f.selectedDriver.portRequired&&!f.formData.connectionInformation.port?Promise.reject(new s.L(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.port")}))):Promise.resolve(),R=()=>{f.formData={connectionInformation:new n.L,settings:{additionalProperties:"",ontopFiles:[]}},Object.values(a.x).forEach(e=>{const t=new i.T(e);f.formData.settings.ontopFiles.push(t)}),f.getOntopFileInfo(a.x.OBDA).required=!0};t.getSupportedDriversData(f.repositoryInfo).success(e=>{f.supportedDriversData=e}).error(e=>{y(m.instant("common.error"),e)}).then(()=>{f.editRepoPage?(I(!0),t.loadPropertiesFile(f.repositoryInfo.params.propertiesFile.value,f.repositoryInfo.location,f.selectedDriver.driverType).success(e=>{let t=f.supportedDriversData.find(t=>t.driverClass===e.driverClass);t&&e.hostName||(t=f.supportedDriversData.find(e=>l.t.isGenericDriver(e.driverType))),f.selectDriver(t.driverType),f.formData.connectionInformation.driverType=t.driverType,f.formData.connectionInformation.driverClass=e.driverClass,f.formData.connectionInformation.password=e.password,f.formData.connectionInformation.username=e.userName,f.formData.connectionInformation.url=e.url,f.formData.settings.additionalProperties=e.additionalProperties,l.t.isGenericDriver(t.driverType)||(f.formData.connectionInformation.hostName=e.hostName,f.formData.connectionInformation.databaseName=e.databaseName,f.formData.connectionInformation.port=e.port?parseInt(e.port,10):void 0),u(),f.updateUrl(),Object.values(a.x).forEach(e=>{const t=f.repositoryInfo.params[e],r=f.getOntopFileInfo(e);t&&(r.fileName=(0,o.W)(t.value))}),f.currentOntopRepoInfo=_.cloneDeep(f.formData)}).error(e=>{y(m.instant("common.error"),e)}).finally(()=>{I(!1)})):f.selectDriver(p.s.GENERIC)})}}}angular.module("graphdb.framework.repositories.ontop-repo.directive",[]).directive("ontopRepo",d),d.$inject=["$uibModal","RepositoriesRestService","toastr","Upload","$translate"]},44207(e,t,r){r.d(t,{T:()=>o});class o{constructor(e,t=!1){this.type=e,this.fileName="",this.loading=!1,this.required=t}}},47775(e,t,r){r.d(t,{t:()=>a});var o=r(12098);class a{constructor(){this.classAvailable=!1,this.downloadDriverUrl="",this.driverClass="",this.driverName="",this.driverType="",this.portRequired=!1,this.urlTemplate=""}static isGenericDriver(e){return e===o.s.GENERIC}static isSnowflakeDriver(e){return e===o.s.SNOWFLAKE}}},54159(e,t,r){r.d(t,{L:()=>o});class o{constructor(e="generic"){this.driverType=e,this.hostName="",this.port=void 0,this.databaseName="",this.username="",this.password="",this.driverClass="",this.url="",this.urlUserInput=""}}},64803(e,t,r){r.d(t,{x:()=>o});const o={OBDA:"obdaFile",OWL:"owlFile",CONSTRAINT:"constraintFile",LENSES:"lensesFile",DB_METADATA:"dbMetadataFile"}},94003(e,t,r){r.d(t,{L:()=>o});class o extends Error{}}}; //# sourceMappingURL=14824.05c024dbd8e6b4b15f3b.bundle.js.map