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);function c(e,r,o,c,d){return{restrict:"E",scope:!1,templateUrl:"js/angular/repositories/templates/ontop-repo.html",link:function(m){m.isGenericDriver=!0,m.defaultUrlTemplate="jdbc:database://localhost:port/database_name",m.ontopProperiesLink="https://ontop-vkg.org/guide/advanced/configuration.html",m.ontopFileType=n.OntopFileType,m.selectedDriver=new p.OntopDriverData,m.supportedDriversData=[],m.formData={connectionInformation:new a.OntopConnectionInformation,settings:{additionalProperties:"",ontopFiles:[]}},m.selectDriver=e=>{m.selectedDriver=m.supportedDriversData.find(r=>r.driverType===e),m.isGenericDriver=p.OntopDriverData.isGenericDriver(m.selectedDriver.driverType),m.editRepoPage&&m.currentOntopRepoInfo&&m.currentOntopRepoInfo.connectionInformation.driverType===e?m.formData=_.cloneDeep(m.currentOntopRepoInfo):(w(),m.formData.connectionInformation.driverType=m.selectedDriver.driverType),m.formData.connectionInformation.driverClass=m.selectedDriver.driverClass,m.updateUrl()},m.getOntopFileInfo=e=>m.formData.settings.ontopFiles.find(r=>e===r.type),m.getHostNameLabel=()=>{const e=p.OntopDriverData.isSnowflakeDriver(m.selectedDriver.driverType)?"ontop.repo.database.snowflake.host_name":"ontop.repo.database.host_name";return d.instant(e)+"*"},m.getDatabaseNameLabel=()=>{let e="";switch(m.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 d.instant(e)},m.updateUrl=()=>{const e=D()||"";m.formData.connectionInformation.url=e+m.formData.connectionInformation.urlUserInput},m.isTestConnectionDisabled=()=>{const e=m.formData.connectionInformation,r=m.selectedDriver;return!(e.driverClass&&e.url&&(!r.portRequired||e.port)&&(p.OntopDriverData.isGenericDriver(r.driverType)||e.hostName&&e.databaseName))},m.testConnection=()=>{b().then(R).then(g).then(O).then(N).then(h).then(()=>r.validateOntopPropertiesConnection(m.repositoryInfo)).then(()=>o.success(d.instant("ontop.repo.successful.connection.msg"))).catch(e=>{e instanceof s.OntopRepositoryError?o.error(e.message):I(d.instant("ontop.repo.failed.to.connect"),e)})},m.editFile=o=>{const n=m.repositoryInfo.params[o.type].label,a=d.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=m.repositoryInfo.params[o.type];return e?e.value:""},dialogTitle:()=>a,location:()=>m.repositoryInfo.location}}).result.then(e=>{r.updateRepositoryFileContent(e.fileLocation,e.content,m.repositoryInfo.location).success(e=>{o.fileName=(0,t.getFileName)(e.fileLocation),m.repositoryInfo.params[o.type].value=e.fileLocation}).error(e=>{I(d.instant("common.error"),e)})})},m.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:m.repositoryInfo.location}};c.upload(n).success(e=>{e.success?(r.fileName=t.name,m.repositoryInfo.params[r.type].value=e.fileLocation):o.error(e.errorMessage)}).error(e=>{I(d.instant("common.error"),e),m.uploadFile=""}).finally(()=>{r.loading=!1})}},m.updateOntopRepo=()=>{const e=m.editRepoPage?m.editRepository:m.createRepo;T().then(b).then(R).then(g).then(O).then(N).then(F).then(h).then(e).catch(e=>{e instanceof s.OntopRepositoryError?o.error(e.message):console.log(e)})},m.onKeyDownInUrlInput=e=>{const r=e.keyCode;if(37===r||39===r||36===r||35===r)return;const o=D();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())},m.onKeyUpInUrlInput=()=>{f()};const f=()=>{const e=D();e&&m.formData.connectionInformation.url.startsWith(e)?m.formData.connectionInformation.urlUserInput=m.formData.connectionInformation.url.substring(e.length):m.formData.connectionInformation.urlUserInput=m.formData.connectionInformation.url},D=()=>p.OntopDriverData.isSnowflakeDriver(m.selectedDriver.driverType)?v():u(),v=()=>{let e=m.selectedDriver.urlTemplate;const r=m.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},u=()=>{let e=m.selectedDriver.urlTemplate;const r=m.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},y=e=>{m.formData.settings.ontopFiles.forEach(r=>{r.loading=e})},h=()=>{y(!0);const e=m.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:m.formData.settings.additionalProperties};return r.updatePropertiesFile(m.repositoryInfo.params.propertiesFile.value,o,m.repositoryInfo.location,m.selectedDriver.driverType).success(e=>{m.repositoryInfo.params.propertiesFile.value=e.fileLocation}).error(e=>{I(d.instant("common.error"),e)}).finally(()=>y(!1))},I=(e,r)=>{const t=getError(r);o.error(t,e)},b=()=>p.OntopDriverData.isGenericDriver(m.selectedDriver.driverType)||m.formData.connectionInformation.hostName?Promise.resolve():Promise.reject(new s.OntopRepositoryError(d.instant("missing.required.field",{fieldName:d.instant("ontop.repo.database.host_name")}))),g=()=>p.OntopDriverData.isGenericDriver(m.selectedDriver.driverType)||m.formData.connectionInformation.databaseName?Promise.resolve():Promise.reject(new s.OntopRepositoryError(d.instant("missing.required.field",{fieldName:d.instant("ontop.repo.database.database_name")}))),O=()=>m.formData.connectionInformation.driverClass?Promise.resolve():Promise.reject(new s.OntopRepositoryError(d.instant("missing.required.field",{fieldName:d.instant("ontop.repo.database.driver_class")}))),N=()=>m.formData.connectionInformation.url?Promise.resolve():Promise.reject(new s.OntopRepositoryError(d.instant("missing.required.field",{fieldName:d.instant("ontop.repo.database.url")}))),T=()=>m.repositoryInfo.id?Promise.resolve():Promise.reject(new s.OntopRepositoryError(d.instant("empty.repoid.warning"))),F=()=>m.getOntopFileInfo(n.OntopFileType.OBDA).fileName?Promise.resolve():Promise.reject(new s.OntopRepositoryError(d.instant("ontop.repo.missing.required.file",{fileName:m.repositoryInfo.params[n.OntopFileType.OBDA].label}))),R=()=>m.selectedDriver.portRequired&&!m.formData.connectionInformation.port?Promise.reject(new s.OntopRepositoryError(d.instant("missing.required.field",{fieldName:d.instant("ontop.repo.database.port")}))):Promise.resolve(),w=()=>{m.formData={connectionInformation:new a.OntopConnectionInformation,settings:{additionalProperties:"",ontopFiles:[]}},Object.values(n.OntopFileType).forEach(e=>{const r=new i.OntopFileInfo(e);m.formData.settings.ontopFiles.push(r)}),m.getOntopFileInfo(n.OntopFileType.OBDA).required=!0};r.getSupportedDriversData(m.repositoryInfo).success(e=>{m.supportedDriversData=e}).error(e=>{I(d.instant("common.error"),e)}).then(()=>{m.editRepoPage?(y(!0),r.loadPropertiesFile(m.repositoryInfo.params.propertiesFile.value,m.repositoryInfo.location,m.selectedDriver.driverType).success(e=>{let r=m.supportedDriversData.find(r=>r.driverClass===e.driverClass);r&&e.hostName||(r=m.supportedDriversData.find(e=>p.OntopDriverData.isGenericDriver(e.driverType))),m.selectDriver(r.driverType),m.formData.connectionInformation.driverType=r.driverType,m.formData.connectionInformation.driverClass=e.driverClass,m.formData.connectionInformation.password=e.password,m.formData.connectionInformation.username=e.userName,m.formData.connectionInformation.url=e.url,m.formData.settings.additionalProperties=e.additionalProperties,p.OntopDriverData.isGenericDriver(r.driverType)||(m.formData.connectionInformation.hostName=e.hostName,m.formData.connectionInformation.databaseName=e.databaseName,m.formData.connectionInformation.port=e.port?parseInt(e.port,10):void 0),f(),m.updateUrl(),Object.values(n.OntopFileType).forEach(e=>{const r=m.repositoryInfo.params[e],o=m.getOntopFileInfo(e);r&&(o.fileName=(0,t.getFileName)(r.value))}),m.currentOntopRepoInfo=_.cloneDeep(m.formData)}).error(e=>{I(d.instant("common.error"),e)}).finally(()=>{y(!1)})):m.selectDriver(l.JdbcDriverType.GENERIC)})}}}angular.module("graphdb.framework.repositories.ontop-repo.directive",[]).directive("ontopRepo",c),c.$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.5d5041c05fca4c0373fa.bundle.js.map