Skip to content
Snippets Groups Projects
Commit 93dbc3df authored by Xiao Gui's avatar Xiao Gui Committed by xgui3783
Browse files

feat: added direct links when kgID is present. hide field if no fetched KG field fits

parent bb55e3d4
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
"type": "Cytoarchitectonic Probabilistic Map",
"name": "Cytoarchitectonic Probabilistic Map for Area hIP1 (IPS)",
"regionName": [
{
{
"regionName": "Area hIP1 (IPS)",
"relationship": "equals"
}
......@@ -1201,14 +1201,14 @@
"relationship": "equals"
}
],
"kgID": "Dataset/d0abf7131bc3460ac188632f40bf0748",
"files": [
{
"filename": "Cytoarchitectonic Probabilistic Map for Area 44 (IFG)",
"name": "Cytoarchitectonic Probabilistic Map for Area 44 (IFG)",
"mimetype": "application/nifti",
"url": "https://neuroglancer.humanbrainproject.org/precomputed/JuBrain/v2.2c/PMaps/Broca_44.nii",
"properties": {},
"kgID": "Dataset/d0abf7131bc3460ac188632f40bf0748"
"properties": {}
}
],
"targetParcellation": "JuBrain Cytoarchitectonic Atlas",
......
const fs = require('fs')
const fetch = require('node-fetch')
const querySingle = (obj) => new Promise((resolve, reject) => {
if(obj.labelIndex){
fetch(`https://kg.humanbrainproject.org/api/smartproxy/kg/_search`,{
"body": JSON.stringify({
query : {
query_string : {
query : obj.name
}
},
post_filter : {
bool : {
must : [{
term : {
_type : 'Dataset'
}
}]
}
}
}),
"method":"POST"
})
.then(res => res.json())
.then(json => {
if(json && json.hits && json.hits.hits && json.hits.hits.length > 0){
const match = json.hits.hits.find(hit => {
console.log(obj.name, hit._source.title.value)
return new RegExp(obj.name.replace(/\(.*?\)/g, '')).test(hit._source.title.value)
})
if(match){
resolve(
Object.assign({}, obj, {kgID : `${match._type}/${match._id}`})
)
}else{
console.log('XXX ',obj.name)
reject(' could not find a match')
}
}else{
// console.log(JSON.stringify(json,null,2))
console.log(obj.name)
reject('json.hits does not exist or is length 0')
}
})
}else{
Promise.all(obj.children.map(item => querySingle(item)))
.then(children => resolve(
Object.assign({}, obj, {children})
))
.catch(err => reject(err))
}
})
fs.readFile('./raw/colin.json','utf-8', (err, data) => {
if(err) throw err
const json = JSON.parse(data)
querySingle(json.parcellations[0].regions[0])
.then(region => {
json.parcellations[0].regions[0] = region
fs.writeFile('./raw/colinNew.json', JSON.stringify(json), 'utf-8', (err) => {
if(err) throw err
console.log('done')
})
})
})
// fetch("https://kg.humanbrainproject.org/api/smartproxy/kg/_search", {
// "credentials":"include",
// "headers":{},
// "referrer":"https://kg.humanbrainproject.org/webapp/?q=area%2044%20%28IFG%29",
// "referrerPolicy":"no-referrer-when-downgrade",
// "body":"{\"query\":{\"query_string\":{\"query\":\"Area hIP1 (IPS)\"}}}",
// "method":"POST",
// "mode":"cors"})
// .then(res => res.json())
// .then(json => {
// fs.writeFile('./raw/hip1.json', JSON.stringify(json), 'utf-8', (err) => {
// if(err) throw err
// console.log('writing finished')
// })
// })
// .catch(console.error)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -62,11 +62,6 @@
[searchResultFile] = "searchResultFile">
</dedicated-viewer>
</div>
<div *ngSwitchCase = "'raw'">
<a href = "about:blank">
See data in Knowledge Graph {{ searchResultFile.kgID }}
</a>
</div>
<div *ngSwitchCase = "'application/nehuba-layer'">
APPLICATION NEHUBA LAYER - NOT YET IMPLEMENTED
<!-- <dedicated-view-controller
......
......@@ -41,6 +41,10 @@ export class KgEntryViewer implements OnInit{
get tableColClass2(){
return `col-xs-8 col-lg-8 tableEntry`
}
get kgHref(){
return `https://kg.humanbrainproject.org/webapp/#${this.kgQueryString}`
}
}
const KGROOT = `https://kg.humanbrainproject.org/api/proxy/kg/`
\ No newline at end of file
......@@ -42,7 +42,7 @@
</div>
</panel-component>
<panel-component [collapseBody] = "true" [bodyCollapsable] = "true">
<panel-component *ngIf = "kgData.publications" [collapseBody] = "true" [bodyCollapsable] = "true">
<div heading>
Related Publication(s)
</div>
......@@ -63,7 +63,7 @@
</div>
</panel-component>
<panel-component [collapseBody] = "true" [bodyCollapsable] = "true">
<panel-component *ngIf = "kgData.preparation" [collapseBody] = "true" [bodyCollapsable] = "true">
<div heading>
Preparation
</div>
......@@ -72,7 +72,7 @@
</div>
</panel-component>
<panel-component [collapseBody] = "true" [bodyCollapsable] = "true">
<panel-component *ngIf = "kgData.methods" [collapseBody] = "true" [bodyCollapsable] = "true">
<div heading>
Methods
</div>
......@@ -83,7 +83,7 @@
</div>
</panel-component>
<panel-component [collapseBody] = "true" [bodyCollapsable] = "true">
<panel-component *ngIf = "kgData.license_info" [collapseBody] = "true" [bodyCollapsable] = "true">
<div heading>
License
</div>
......@@ -92,7 +92,7 @@
</div>
</panel-component>
<panel-component [collapseBody] = "true" [bodyCollapsable] = "true">
<panel-component *ngIf = "kgData.files" [collapseBody] = "true" [bodyCollapsable] = "true">
<div heading>
Files
</div>
......@@ -103,7 +103,7 @@
</div>
</panel-component>
<panel-component [collapseBody] = "true" [bodyCollapsable] = "true">
<panel-component *ngIf = "kgData.subjects" [collapseBody] = "true" [bodyCollapsable] = "true">
<div heading>
Subjects
</div>
......@@ -116,6 +116,9 @@
</panel-component>
</readmore-component>
<a target = "_blank" [href] = "kgHref">
See the entry in Knowledge Graph
</a>
</div>
<ng-template #showDefault>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment