graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 10.4 kB
JavaScript
export const __webpack_id__=14824;export const __webpack_ids__=[12098,14824,44207,47775,54159,64803,94003];export const __webpack_modules__={12098:(e,r,o)=>{o.r(r),o.d(r,{JdbcDriverType:()=>t});const t={GENERIC:"generic",MY_SQL:"mySQL",POSTGRESS:"postgreSQL",ORACLE:"oracle",MS_SQL:"msSQL",DB2:"DB2",DREMIO:"dremio",DATABRICKS:"databricks",SNOWFLAKE:"snowflake"}},14824:(e,r,o)=>{o.r(r);var t=o(46591),n=o(64803),a=o(54159),i=o(44207),s=o(94003),p=o(47775),l=o(12098);const c=o(304).LoggerProvider.logger;function d(e,r,o,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=n.OntopFileType,f.selectedDriver=new p.OntopDriverData,f.supportedDriversData=[],f.formData={connectionInformation:new a.OntopConnectionInformation,settings:{additionalProperties:"",ontopFiles:[]}},f.selectDriver=e=>{f.selectedDriver=f.supportedDriversData.find(r=>r.driverType===e),f.isGenericDriver=p.OntopDriverData.isGenericDriver(f.selectedDriver.driverType),f.editRepoPage&&f.currentOntopRepoInfo&&f.currentOntopRepoInfo.connectionInformation.driverType===e?f.formData=_.cloneDeep(f.currentOntopRepoInfo):(E(),f.formData.connectionInformation.driverType=f.selectedDriver.driverType),f.formData.connectionInformation.driverClass=f.selectedDriver.driverClass,f.updateUrl()},f.getOntopFileInfo=e=>f.formData.settings.ontopFiles.find(r=>e===r.type),f.getHostNameLabel=()=>{const e=p.OntopDriverData.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 l.JdbcDriverType.SNOWFLAKE:e="ontop.repo.database.warehouse.database_name";break;case l.JdbcDriverType.DATABRICKS:e="ontop.repo.database.http_path.database_name";break;case l.JdbcDriverType.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,r=f.selectedDriver;return!(e.driverClass&&e.url&&(!r.portRequired||e.port)&&(p.OntopDriverData.isGenericDriver(r.driverType)||e.hostName&&e.databaseName))},f.testConnection=()=>{b().then(w).then(O).then(N).then(T).then(I).then(()=>r.validateOntopPropertiesConnection(f.repositoryInfo)).then(()=>o.success(m.instant("ontop.repo.successful.connection.msg"))).catch(e=>{e instanceof s.OntopRepositoryError?o.error(e.message):g(m.instant("ontop.repo.failed.to.connect"),e)})},f.editFile=o=>{const n=f.repositoryInfo.params[o.type].label,a=m.instant("update.file.edit.content.header",{fileName:n});e.open({templateUrl:"js/angular/templates/modal/editRepoFile.html",controller:"EditRepositoryFileCtrl",windowClass:"update-ontop-repo-dialog",resolve:{file:()=>{const e=f.repositoryInfo.params[o.type];return e?e.value:""},dialogTitle:()=>a,location:()=>f.repositoryInfo.location}}).result.then(e=>{r.updateRepositoryFileContent(e.fileLocation,e.content,f.repositoryInfo.location).success(e=>{o.fileName=(0,t.getFileName)(e.fileLocation),f.repositoryInfo.params[o.type].value=e.fileLocation}).error(e=>{g(m.instant("common.error"),e)})})},f.uploadOntopFile=(e,r)=>{if(e&&e.length){const t=e[0];r.loading=!0;const n={url:"rest/repositories/file/upload",data:{file:t,location:f.repositoryInfo.location}};d.upload(n).success(e=>{e.success?(r.fileName=t.name,f.repositoryInfo.params[r.type].value=e.fileLocation):o.error(e.errorMessage)}).error(e=>{g(m.instant("common.error"),e),f.uploadFile=""}).finally(()=>{r.loading=!1})}},f.updateOntopRepo=()=>{const e=f.editRepoPage?f.editRepository:f.createRepo;F().then(b).then(w).then(O).then(N).then(T).then(R).then(I).then(e).catch(e=>{e instanceof s.OntopRepositoryError?o.error(e.message):c.info(e)})},f.onKeyDownInUrlInput=e=>{const r=e.keyCode;if(37===r||39===r||36===r||35===r)return;const o=v();if(!o)return;const t=e.ctrlKey||e.metaKey;if(t&&65===r||t&&67===r)return;const n=e.target.selectionStart;8===r&&n-1<o.length&&(e.preventDefault(),e.stopPropagation()),n<o.length&&(e.preventDefault(),e.stopPropagation())},f.onKeyUpInUrlInput=()=>{D()};const D=()=>{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=()=>p.OntopDriverData.isSnowflakeDriver(f.selectedDriver.driverType)?u():y(),u=()=>{let e=f.selectedDriver.urlTemplate;const r=f.formData.connectionInformation;return r.hostName&&(e=e.replace("{identifier}",r.hostName)),r.port&&(e=e.replace(".snowflakecomputing.com/?",`.snowflakecomputing.com:${r.port}/?`)),r.databaseName&&(e=e.replace("{database}",r.databaseName)),e},y=()=>{let e=f.selectedDriver.urlTemplate;const r=f.formData.connectionInformation;return r.hostName&&(e=r.port?e.replace("{hostport}",`${r.hostName}:${r.port}`):e.replace("{hostport}",`${r.hostName}`)),r.databaseName&&(e=e.replace("{database}",r.databaseName)),e},h=e=>{f.formData.settings.ontopFiles.forEach(r=>{r.loading=e})},I=()=>{h(!0);const e=f.formData.connectionInformation,o={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 r.updatePropertiesFile(f.repositoryInfo.params.propertiesFile.value,o,f.repositoryInfo.location,f.selectedDriver.driverType).success(e=>{f.repositoryInfo.params.propertiesFile.value=e.fileLocation}).error(e=>{g(m.instant("common.error"),e)}).finally(()=>h(!1))},g=(e,r)=>{const t=getError(r);o.error(t,e)},b=()=>p.OntopDriverData.isGenericDriver(f.selectedDriver.driverType)||f.formData.connectionInformation.hostName?Promise.resolve():Promise.reject(new s.OntopRepositoryError(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.host_name")}))),O=()=>p.OntopDriverData.isGenericDriver(f.selectedDriver.driverType)||f.formData.connectionInformation.databaseName?Promise.resolve():Promise.reject(new s.OntopRepositoryError(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.database_name")}))),N=()=>f.formData.connectionInformation.driverClass?Promise.resolve():Promise.reject(new s.OntopRepositoryError(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.driver_class")}))),T=()=>f.formData.connectionInformation.url?Promise.resolve():Promise.reject(new s.OntopRepositoryError(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.url")}))),F=()=>f.repositoryInfo.id?Promise.resolve():Promise.reject(new s.OntopRepositoryError(m.instant("empty.repoid.warning"))),R=()=>f.getOntopFileInfo(n.OntopFileType.OBDA).fileName?Promise.resolve():Promise.reject(new s.OntopRepositoryError(m.instant("ontop.repo.missing.required.file",{fileName:f.repositoryInfo.params[n.OntopFileType.OBDA].label}))),w=()=>f.selectedDriver.portRequired&&!f.formData.connectionInformation.port?Promise.reject(new s.OntopRepositoryError(m.instant("missing.required.field",{fieldName:m.instant("ontop.repo.database.port")}))):Promise.resolve(),E=()=>{f.formData={connectionInformation:new a.OntopConnectionInformation,settings:{additionalProperties:"",ontopFiles:[]}},Object.values(n.OntopFileType).forEach(e=>{const r=new i.OntopFileInfo(e);f.formData.settings.ontopFiles.push(r)}),f.getOntopFileInfo(n.OntopFileType.OBDA).required=!0};r.getSupportedDriversData(f.repositoryInfo).success(e=>{f.supportedDriversData=e}).error(e=>{g(m.instant("common.error"),e)}).then(()=>{f.editRepoPage?(h(!0),r.loadPropertiesFile(f.repositoryInfo.params.propertiesFile.value,f.repositoryInfo.location,f.selectedDriver.driverType).success(e=>{let r=f.supportedDriversData.find(r=>r.driverClass===e.driverClass);r&&e.hostName||(r=f.supportedDriversData.find(e=>p.OntopDriverData.isGenericDriver(e.driverType))),f.selectDriver(r.driverType),f.formData.connectionInformation.driverType=r.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,p.OntopDriverData.isGenericDriver(r.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),D(),f.updateUrl(),Object.values(n.OntopFileType).forEach(e=>{const r=f.repositoryInfo.params[e],o=f.getOntopFileInfo(e);r&&(o.fileName=(0,t.getFileName)(r.value))}),f.currentOntopRepoInfo=_.cloneDeep(f.formData)}).error(e=>{g(m.instant("common.error"),e)}).finally(()=>{h(!1)})):f.selectDriver(l.JdbcDriverType.GENERIC)})}}}angular.module("graphdb.framework.repositories.ontop-repo.directive",[]).directive("ontopRepo",d),d.$inject=["$uibModal","RepositoriesRestService","toastr","Upload","$translate"]},44207:(e,r,o)=>{o.r(r),o.d(r,{OntopFileInfo:()=>t});class t{constructor(e,r=!1){this.type=e,this.fileName="",this.loading=!1,this.required=r}}},47775:(e,r,o)=>{o.r(r),o.d(r,{OntopDriverData:()=>n});var t=o(12098);class n{constructor(){this.classAvailable=!1,this.downloadDriverUrl="",this.driverClass="",this.driverName="",this.driverType="",this.portRequired=!1,this.urlTemplate=""}static isGenericDriver(e){return e===t.JdbcDriverType.GENERIC}static isSnowflakeDriver(e){return e===t.JdbcDriverType.SNOWFLAKE}}},54159:(e,r,o)=>{o.r(r),o.d(r,{OntopConnectionInformation:()=>t});class t{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,r,o)=>{o.r(r),o.d(r,{OntopFileType:()=>t});const t={OBDA:"obdaFile",OWL:"owlFile",CONSTRAINT:"constraintFile",LENSES:"lensesFile",DB_METADATA:"dbMetadataFile"}},94003:(e,r,o)=>{o.r(r),o.d(r,{OntopRepositoryError:()=>t});class t extends Error{}}};
//# sourceMappingURL=14824.a3bc164c5bf4313f5276.bundle.js.map