File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ const canvasCtxMenuItems = [
2929 } ,
3030 { label : "External Turtle Files" , action : "ExternalTurtleFilesInputNode" } ,
3131 { label : "External SPARQL Endpoint" , action : "ExternalSparqlEndpointInputNode" } ,
32- { label : "JavaScript Input" , action : "JavaScriptInputNode" } ,
32+ { label : "JavaScript Input" , action : "JavaScriptInputNode" ,
33+ submenu : [
34+ { label : "Template: JSON array to triple store" , action : "ex_JavaScriptInputNode_JsonArrToTripleStore" }
35+ ]
36+ } ,
3337 // { label: "Output Viewer with initial input", action: "OutputViewNodeWithInitialInput" },
3438 ]
3539 } ,
Original file line number Diff line number Diff line change @@ -135,7 +135,20 @@ DELETE {
135135} WHERE {
136136 ?user a ff:Citizen ;
137137 ff:hasBirthday ?bday .
138- }`
138+ }` ,
139+ "ex_JavaScriptInputNode_JsonArrToTripleStore" : `let store = newStore()
140+ const a = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
141+ const ff = function(localName) { return "https://foerderfunke.org/default#" + localName }
142+ let count = 0
143+
144+ for (let element of JSON.parse(input)) {
145+ let individual = ff("class" + (count ++))
146+ addTripleToStore(store, individual, a, ff("Class"))
147+ addTripleToStore(store, individual, ff("hasTitle"), element.Title)
148+ // ...
149+ }
150+
151+ return storeToTurtle(store)`
139152}
140153
141154export function factoryCreateNode ( nodeClass , initialValues , graph ) {
You can’t perform that action at this time.
0 commit comments