UNPKG

graphdb-workbench

Version:
3 lines 16.9 kB
/*! For license information please see 38785.9feee26ec9bb94a9d1cc.bundle.js.LICENSE.txt */ export const __webpack_id__=38785;export const __webpack_ids__=[38785,46844,53627,64341,72745];export const __webpack_modules__={38785:(e,t,n)=>{n.r(t),n(82493),n(76933),n(98599),n(72745),n(53627);var o=n(76752),r=n(27030),a=n(98980),i=n(64341);angular.module("graphdb.framework.impex.export.controllers",["ngCookies","ui.bootstrap","toastr","graphdb.framework.core.services.repositories","graphdb.framework.core.services.jwtauth","graphdb.workbench.utils.filetypes","graphdb.framework.rest.export.service"]).controller("ExportCtrl",["$scope","$http","$location","$timeout","ModalService","filterFilter","$repositories","toastr","ExportRestService","RDF4JRepositoriesRestService","FileTypes","$translate","AuthTokenService","$uibModal","RDF4JRepositoriesService",function(e,t,n,s,l,p,c,d,u,g,f,h,m,x,y){e.getActiveRepository=function(){return c.getActiveRepository()},e.MAX_LOADED_GRAPHS=1e5,e.exportFormats=f,e.deleting={},e.showExportDDTooltip=!0,e.page=1,e.pageSize=50,e.pageSizeOptions=[10,20,50,100],e.displayGraphs=[],e.exportFilter="",e.export=!0,e.exportMultipleGraphs=!1,e.hasMoreGraphs=!1,e.repoExportFormat={name:"TriG",type:"application/x-trig",extension:".trig"},e.selectedGraphs={exportGraphs:{}},e.$watch(function(){return c.getActiveRepository()},function(){e.exportFilter="",e.getGraphs(),e.selectedAll=!1,s(function(){e.changePageSize(e.pageSize)},100)}),e.isShacl=function(e){return"http%3A%2F%2Frdf4j.org%2Fschema%2Frdf4j%23SHACLShapeGraph"===e},e.getGraphs=function(){e.getActiveRepository()?(e.loader=!0,e.hasMoreGraphs=!1,g.getGraphs(e.getActiveRepository(),e.MAX_LOADED_GRAPHS+1).success(t=>{t.results.bindings.length>e.MAX_LOADED_GRAPHS&&(e.hasMoreGraphs=!0,t.results.bindings.pop()),t.results.bindings.unshift({contextID:{type:"default",value:"import.default.graph"}}),e.graphsByValue={},Object.keys(t.results.bindings).forEach(function(n){const o=t.results.bindings[n];"bnode"===o.contextID.type?o.contextID.value="_:"+o.contextID.value:"default"===o.contextID.type?(o.contextID.uri=encodeURIComponent("http://www.openrdf.org/schema/sesame#nil"),o.contextID.clearUri="DEFAULT",o.contextID.exportUri="null",o.contextID.longName="default graph"):(o.contextID.uri=encodeURIComponent(o.contextID.value),o.contextID.clearUri="GRAPH <"+o.contextID.value+">",o.contextID.exportUri=encodeURIComponent("<"+o.contextID.value+">"),o.contextID.longName="named graph "+o.contextID.value),e.graphsByValue[o.contextID.value]=o.contextID}),e.graphs=t.results.bindings,e.filteredGraphs=(0,a.cloneDeep)(e.graphs),e.displayGraphs=e.filteredGraphs.slice(e.pageSize*(e.page-1),e.pageSize*e.page),e.loader=!1,e.selectedGraphs.exportGraphs={},e.matchedElements=e.graphs}).error(function(t,n){const o=getError(t,n);"There is no active location!"===o&&(c.setRepository(""),d.error(o,h.instant("common.error"))),e.loader=!1})):e.loader=!1},e.onGraphSearch=function(){e.matchedElements=[],e.deselectAll(),e.filterResults()},e.filterResults=function(){angular.forEach(e.graphs,function(t){-1!==t.contextID.value.indexOf(e.exportFilter)&&e.matchedElements.push(t)})},e.downloadExport=function(e,t){let n=e+"&Accept="+encodeURIComponent(t.type);const o=m.getAuthToken();o&&(n=n+"&authToken="+encodeURIComponent(o));let r=window.open(n);s(function(){"about:blank"!==r.document.location.href&&(r.close(),d.error("Could not export graph. Check GraphDB logs for detailed reason."))},100)},e.openExportDDTooltip=function(){e.showExportDDTooltip&&(s(function(){$("#tooltipTarget").trigger("showExportDDTooltip")},0),s(function(){$("#tooltipTarget").trigger("showExportDDTooltip")},3e3),e.showExportDDTooltip=!1)},e.exportRepo=function(t,n){"application/rdf+xml"===t.type||"text/plain"===t.type||"text/turtle"===t.type||"application/x-turtlestar"===t.type||"text/rdf+n3"===t.type?l.openSimpleModal({title:h.instant("common.warning"),message:(0,r.Gz)(h.instant("export.format.warning.msg")),warning:!0}).result.then(function(){e.startDownload(t,n)}):e.startDownload(t,n)},e.downloadAllGraphs=function(){y.downloadGraphsAsFile(e.getActiveRepository()).then(function({data:e,filename:t}){(0,o.saveAs)(e,t)}).catch(function(e){e.data.text().then(t=>{431===e.status?d.error(e.statusText,h.instant("common.error")):d.error(t,h.instant("common.error"))})})},e.openJSONLDExportSettings=function(t,n){x.open({templateUrl:"js/angular/core/components/export-settings-modal/exportSettingsModal.html",controller:i.ExportSettingsCtrl,size:"lg",scope:e,resolve:{format:function(){return t.name}}}).result.then(function(r){const a="framed"===r.currentMode.name?"frame":"context",i=r.link?`<${r.link}>; rel="http://www.w3.org/ns/json-ld#${a}"`:"";!function(e,t,n,r,a,i){const s={accept:e.type+";profile="+i.link,link:n};u.getExportedStatementsAsJSONLD(t,r,a,m.getAuthToken(),s).then(function({data:e,filename:t}){(0,o.saveAs)(e,t)}).catch(function(e){e.data.text().then(t=>{431===e.status?d.error(e.statusText,h.instant("common.error")):d.error(t,h.instant("common.error"))})})}(t,n,i,c.getActiveRepositoryObject(),e.graphsByValue,r.currentMode)})},e.startDownload=function(t,n){let o;const r=c.getActiveRepositoryObject();o=n?`repositories/${r.id}/statements?infer=false&context=${e.graphsByValue[n.value].exportUri}&location=${encodeURIComponent(r.location)}`:`repositories/${r.id}/statements?infer=false&location=${encodeURIComponent(r.location)}`,e.downloadExport(o,t)},e.hasMultipleSelected=function(){if(_.isEmpty(e.selectedGraphs.exportGraphs))return!_.isEmpty(e.selectedGraphs.exportGraphs);for(const t in e.selectedGraphs.exportGraphs)if(!0===e.selectedGraphs.exportGraphs[t])return!0;return!1},e.openJSONLDExportSettingsForSelectedGraphs=function(t){const n=Object.keys(e.selectedGraphs.exportGraphs).filter(t=>e.selectedGraphs.exportGraphs[t]).map(t=>e.graphsByValue[t].exportUri);n?e.openJSONLDExportSettings(t,n):l.openSimpleModal({title:h.instant("export.multiple.graph"),message:h.instant("export.check.graphs.msg"),warning:!0})},e.exportSelectedGraphs=function(t){let n="";for(const t in e.selectedGraphs.exportGraphs)e.selectedGraphs.exportGraphs[t]&&(n+="context="+e.graphsByValue[t].exportUri+"&");if(n){const o=function(){n=n.substring(0,n.length-1);const o="repositories/"+e.getActiveRepository()+"/statements?infer=false&"+n;e.downloadExport(o,t)};"application/rdf+xml"===t.type||"text/plain"===t.type||"text/turtle"===t.type||"application/x-turtlestar"===t.type||"text/rdf+n3"===t.type?l.openSimpleModal({title:h.instant("common.warning"),message:(0,r.Gz)(h.instant("export.format.warning.msg")),warning:!0}).result.then(function(){o()}):o()}else l.openSimpleModal({title:h.instant("export.multiple.graph"),message:h.instant("export.check.graphs.msg"),warning:!0})},e.$watch("exportFilter",function(){if(e.filteredGraphs=p(e.graphs,e.exportFilter),e.getActiveRepository()&&angular.element(document).find(".btn.btn-secondary.btn-sm.dropdown-toggle span").length){const t=angular.element(document).find(".btn.btn-secondary.btn-sm.dropdown-toggle span")[0].innerHTML.trim();let n;"All"===t&&(n=e.filteredGraphs.length),e.filteredGraphs&&e.filteredGraphs.length>e.pageSize&&"All"!==t&&(n=e.pageSize),e.changePageSize(n),e.changePagination()}}),e.changePagination=function(){e.selectedAll=!1,angular.isDefined(e.filteredGraphs)&&(e.displayGraphs=e.filteredGraphs.slice(e.pageSize*(e.page-1),e.pageSize*e.page))},e.changePageSize=function(t){$(".ot-graph-page-size").removeClass("active"),e.page=1,t&&(e.pageSize=t,e.changePagination()),e.filteredGraphs&&""!==e.exportFilter&&(e.displayGraphs=e.filteredGraphs)},e.checkAll=function(){e.selectedAll=e.selectedAll||!1,angular.forEach(e.displayGraphs,function(t){t.contextID.uri&&(e.selectedGraphs.exportGraphs[t.contextID.value]=e.selectedAll)})},e.deselectAll=function(){e.selectedAll=!1,angular.forEach(e.displayGraphs,function(t){t.contextID.uri&&(e.selectedGraphs.exportGraphs[t.contextID.value]=!1)})},e.dropRepository=function(){e.canWriteActiveRepo()&&(e.deleting["*"]=!0,l.openSimpleModal({title:h.instant("export.confirm.clear.msg"),message:h.instant("export.warning.clear.repo.msg",{repo:c.getActiveRepository()}),warning:!0}).result.then(function(){s(function(){g.addStatements(c.getActiveRepository(),"update=CLEAR ALL").then(function(){e.deleting["*"]=!1,d.success(h.instant("export.cleared.repo",{repo:c.getActiveRepository()})),e.getGraphs()},function(t){e.deleting["*"]=!1;const n=t.data;"string"==typeof n&&n.indexOf("Clearing all statements in the repository is incompatible with collecting history")>-1?d.error(h.instant("export.clearing.statements.warning")):d.error(h.instant("export.cleared.repo.failed.msg",{repo:c.getActiveRepository()}),t)})},100)}))},e.dropContext=function(t){e.canWriteActiveRepo()&&(angular.isDefined(t)?function(t){const n=t.contextID.longName;e.deleting[t]=!0,l.openSimpleModal({title:h.instant("export.confirm.clear.graph"),message:h.instant("export.clear.graph.warning",{longName:n}),warning:!0}).result.then(function(){s(function(){const o=`update=CLEAR ${t.contextID.clearUri}`;g.addStatements(c.getActiveRepository(),o).then(function(){e.deleting[t]=!1,d.success(h.instant("export.cleared.graph",{longName:n})),e.getGraphs(),e.exportFilter="",e.filteredGraphs.length=0,e.updateResults(),e.changePageSize(e.pageSize)},function(o){e.deleting[t]=!1,d.error(h.instant("export.clear.graph.msg",{longName:n}),getError(o,o.status))})},100)},function(){e.deleting[t]=!1})}(t):function(t){const n=[];angular.forEach(e.selectedGraphs.exportGraphs,function(e,t){e&&n.push(t)}),n.length>0&&(e.deleting[t]=!0,l.openSimpleModal({title:h.instant("export.confirm.clear.graph"),message:h.instant("export.warning.clear.graph.msg"),warning:!0}).result.then(function(){s(function(){let t=0;angular.forEach(n,function(o){const r=`update=CLEAR ${e.graphsByValue[o].clearUri}`;g.addStatements(c.getActiveRepository(),r).then(function(){e.loader=!0,e.selectedGraphs.exportGraphs[o]=!1,delete e.selectedGraphs.exportGraphs[o],t++,n.length===t&&(e.selectedAll=!1,e.exportFilter="",e.filteredGraphs.length=0,e.getGraphs(),e.updateResults(),e.changePageSize(e.pageSize),d.success(h.instant("export.cleared.graph.msg")),e.loader=!1)},function(t){const n=e.graphsByValue[o].longName;d.error(h.instant("export.clear.graph.msg",{longName:n}),getError(t,t.status)),e.selectedAll=!1})})},100)},function(){e.deleting[t]=!1}))}(t))}}])},53627:()=>{angular.module("graphdb.framework.rest.export.service",[]).factory("ExportRestService",t),t.$inject=["$http","$repositories","$translate"];const e="repositories";function t(t,n,o){return{getExportedStatementsAsJSONLD:function(n,o,r,a,i){const s=`${e}/${o.id}/statements?infer=false`,l={location:o.location},p={accept:i.accept};return Array.isArray(n)?l.context=n.map(e=>decodeURIComponent(e)):n&&(l.context=decodeURIComponent(r[n.value].exportUri)),a&&(l.authToken=a),i.link&&""!==i.link&&(p.link=i.link),t({url:s,method:"GET",params:l,headers:p,responseType:"blob"}).then(function(e){const t=e.data;let n=e.headers()["content-disposition"].split("filename=")[1];return n=n.substring(0,n.length),{data:t,filename:n}})}}}},64341:(e,t,n)=>{function o(e,t,n,o,r){e.JSONLDModes=[{name:"framed",link:"http://www.w3.org/ns/json-ld#framed"},{name:"expanded",link:"http://www.w3.org/ns/json-ld#expanded"},{name:"flattened",link:"http://www.w3.org/ns/json-ld#flattened"},{name:"compacted",link:"http://www.w3.org/ns/json-ld#compacted"}],e.JSONLDModesNames=e.JSONLDModes.reduce(function(e,t){return e[t.name]=t.name,e},{}),e.JSONLDFramedModes=[e.JSONLDModesNames.framed],e.JSONLDContextModes=[e.JSONLDModesNames.compacted,e.JSONLDModesNames.flattened],e.defaultMode=e.JSONLDModes.find(e=>"expanded"===e.name),e.currentMode=e.defaultMode,e.link=null,e.fileFormat=r.toLowerCase(),e.setJSONLDSettingsToLocalStorage=function(e,t,r){n.set(o.JSONLD_EXPORT_SETTINGS,JSON.stringify({jsonldFormName:e,jsonldFormLink:t,jsonldLink:r}))},e.cancel=function(){t.dismiss()},e.reset=function(){e.currentMode=e.defaultMode,e.link="",e.setJSONLDSettingsToLocalStorage(e.currentMode.name,e.currentMode.link,e.link)},e.clearLinkInput=function(){e.link="",e.setJSONLDSettingsToLocalStorage(e.currentMode.name,e.currentMode.link,e.link)},e.exportJsonLD=function(){e.setJSONLDSettingsToLocalStorage(e.currentMode.name,e.currentMode.link,e.link),t.close({currentMode:e.currentMode,link:e.link})},function(){const t=n.get(o.JSONLD_EXPORT_SETTINGS);t&&(e.currentMode=e.JSONLDModes.find(e=>e.name===t.jsonldFormName),e.link=t.jsonldLink)}()}n.r(t),n.d(t,{ExportSettingsCtrl:()=>o}),angular.module("graphdb.framework.core.components.export-settings-modal",["graphdb.framework.utils.localstorageadapter"]).controller("ExportSettingsCtrl",o),o.$inject=["$scope","$uibModalInstance","LocalStorageAdapter","LSKeys","format"]},72745:()=>{angular.module("graphdb.workbench.utils.filetypes",[]).value("FileTypes",[{name:"JSON",translateKey:"download.as.json",type:"application/rdf+json",extension:".json"},{name:"JSON-LD",translateKey:"download.as.jsonld",type:"application/ld+json",extension:".jsonld"},{name:"NDJSON-LD",translateKey:"download.as.ndjsonld",type:"application/x-ld+ndjson",extension:".ndjsonld"},{name:"RDF-XML",translateKey:"download.as.rdfxml",type:"application/rdf+xml",extension:".rdf"},{name:"N3",translateKey:"download.as.n3",type:"text/rdf+n3",extension:".n3"},{name:"N-Triples",translateKey:"download.as.ntriples",type:"text/plain",extension:".nt"},{name:"N-Quads",translateKey:"download.as.nquads",type:"text/x-nquads",extension:".nq"},{name:"Turtle",translateKey:"download.as.turtle",type:"text/turtle",extension:".ttl"},{name:"Turtle*",translateKey:"download.as.turtlestar",type:"application/x-turtlestar",extension:".ttls"},{name:"TriX",translateKey:"download.as.trix",type:"application/trix",extension:".trix"},{name:"TriG",translateKey:"download.as.trig",type:"application/x-trig",extension:".trig"},{name:"TriG*",translateKey:"download.as.trigstar",type:"application/x-trigstar",extension:".trigs"},{name:"Binary RDF",translateKey:"download.as.binaryrdf",type:"application/x-binary-rdf",extension:".brf"}])},76752:function(e,t,n){var o,r=r||function(e){if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r=e.webkitRequestFileSystem,a=e.requestFileSystem||r||e.mozRequestFileSystem,i=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",l=0,p=function(t){var o=function(){"string"==typeof t?n().revokeObjectURL(t):t.remove()};e.chrome?o():setTimeout(o,500)},c=function(e,t,n){for(var o=(t=[].concat(t)).length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(e){i(e)}}},d=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e},u=function(t,i){t=d(t);var u,g,f,h=this,m=t.type,x=!1,y=function(){c(h,"writestart progress write writeend".split(" "))},w=function(){!x&&u||(u=n().createObjectURL(t)),g?g.location.href=u:null==e.open(u,"_blank")&&"undefined"!=typeof safari&&(e.location.href=u),h.readyState=h.DONE,y(),p(u)},S=function(e){return function(){if(h.readyState!==h.DONE)return e.apply(this,arguments)}},D={create:!0,exclusive:!1};if(h.readyState=h.INIT,i||(i="download"),o)return u=n().createObjectURL(t),o.href=u,o.download=i,void setTimeout(function(){var e,t;e=o,t=new MouseEvent("click"),e.dispatchEvent(t),y(),p(u),h.readyState=h.DONE});e.chrome&&m&&m!==s&&(f=t.slice||t.webkitSlice,t=f.call(t,0,t.size,s),x=!0),r&&"download"!==i&&(i+=".download"),(m===s||r)&&(g=e),a?(l+=t.size,a(e.TEMPORARY,l,S(function(e){e.root.getDirectory("saved",D,S(function(e){var n=function(){e.getFile(i,D,S(function(e){e.createWriter(S(function(n){n.onwriteend=function(t){g.location.href=e.toURL(),h.readyState=h.DONE,c(h,"writeend",t),p(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&w()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=h["on"+e]}),n.write(t),h.abort=function(){n.abort(),h.readyState=h.DONE},h.readyState=h.WRITING}),w)}),w)};e.getFile(i,{create:!1},S(function(e){e.remove(),n()}),S(function(e){e.code===e.NOT_FOUND_ERR?n():w()}))}),w)}),w)):w()},g=u.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t){return navigator.msSaveOrOpenBlob(d(e),t)}:(g.abort=function(){var e=this;e.readyState=e.DONE,c(e,"abort")},g.readyState=g.INIT=0,g.WRITING=1,g.DONE=2,g.error=g.onwritestart=g.onprogress=g.onwrite=g.onabort=g.onerror=g.onwriteend=null,function(e,t){return new u(e,t)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);e.exports?e.exports.saveAs=r:null!==n.amdD&&null!=n.amdO&&(void 0===(o=function(){return r}.apply(t,[]))||(e.exports=o))}}; //# sourceMappingURL=38785.9feee26ec9bb94a9d1cc.bundle.js.map