Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linked-data-browser
Manage
Activity
Members
Labels
Plan
Issues
12
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Value Flows
VF Code Experiments
linked-data-browser
Commits
b789c935
Commit
b789c935
authored
9 years ago
by
Mikey
Browse files
Options
Downloads
Patches
Plain Diff
default quad.graph to fetched url of graph
use latest n3 which provides wildcard graph query for store.find
parent
babb325a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
package.json
+1
-1
1 addition, 1 deletion
package.json
src/effects/parse.js
+23
-5
23 additions, 5 deletions
src/effects/parse.js
src/getters.js
+2
-2
2 additions, 2 deletions
src/getters.js
with
26 additions
and
8 deletions
package.json
+
1
−
1
View file @
b789c935
...
...
@@ -33,7 +33,7 @@
"
jsonld
"
:
"
^0.4.2
"
,
"
linkeddata-vocabs
"
:
"
^0.7.0
"
,
"
lodash
"
:
"
^3.10.1
"
,
"
n3
"
:
"
^0.4.5
"
,
"
n3
"
:
"
github:rubenverborgh/N3.js#04f4e21f4ccb351587dc00a3f26340b28d4bb10f
"
,
"
read-blob
"
:
"
^1.1.0
"
,
"
redux
"
:
"
^3.0.3
"
,
"
redux-actions
"
:
"
^0.8.0
"
,
...
...
This diff is collapsed.
Click to expand it.
src/effects/parse.js
+
23
−
5
View file @
b789c935
...
...
@@ -11,7 +11,7 @@ function parseMiddleware ({ dispatch, getState }) {
const
urlify
=
createUrlify
(
action
.
payload
.
url
)
return
action
.
type
===
PARSE
?
parserByFormat
(
action
.
payload
.
type
)(
action
.
payload
.
content
)
?
parserByFormat
(
action
.
payload
.
type
)(
action
.
payload
)
.
then
(
urlify
)
.
catch
((
error
)
=>
{
throw
urlify
({
error
})
...
...
@@ -25,7 +25,7 @@ function parserByFormat (format) {
case
'
application/octet
'
:
case
'
application/json
'
:
case
'
application/ld+json
'
:
return
(
content
)
=>
{
return
(
{
content
,
url
}
)
=>
{
let
json
=
JSON
.
parse
(
content
)
var
context
return
processContext
(
json
[
'
@context
'
])
...
...
@@ -33,7 +33,10 @@ function parserByFormat (format) {
json
[
'
@context
'
]
=
context
=
ctx
return
JsonLd
.
toRDF
(
json
,
{
format
:
'
application/nquads
'
})
})
.
then
(
parserByFormat
(
'
application/n-quads
'
))
.
then
((
nquads
)
=>
{
return
{
content
:
nquads
,
url
}
})
.
then
(
parserByFormat
(
'
application/nquads
'
))
.
then
((
graph
)
=>
{
return
{
content
:
content
,
...
...
@@ -46,9 +49,11 @@ function parserByFormat (format) {
case
'
application/trig
'
:
case
'
text/turtle
'
:
case
'
application/n-triples
'
:
case
'
application/ntriples
'
:
case
'
application/n-quads
'
:
case
'
application/nquads
'
:
var
parser
=
N3Parser
({
format
})
return
(
content
)
=>
{
return
(
{
content
,
url
}
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
quads
=
[]
parser
.
parse
(
content
,
(
err
,
quad
,
prefixes
)
=>
{
...
...
@@ -56,6 +61,9 @@ function parserByFormat (format) {
if
(
quad
)
{
quads
.
push
(
quad
)
}
else
{
// add url as graph to quads if not already assigned
quads
=
quads
.
map
(
defaultQuadGraph
(
url
))
// return
resolve
({
content
,
quads
,
prefixes
})
}
})
...
...
@@ -63,7 +71,7 @@ function parserByFormat (format) {
}
default
:
return
content
=>
{
return
({
content
})
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
reject
(
new
Error
(
`
effects/parse: unable to parse Content-Type
${
format
}
.
...
...
@@ -110,3 +118,13 @@ const parse = createAction(PARSE)
export
default
parseMiddleware
export
{
parse
}
// TODO util-ify
function
defaultQuadGraph
(
graph
)
{
return
(
quad
)
=>
{
if
(
!
quad
.
graph
)
{
return
Object
.
assign
({},
quad
,
{
graph
})
}
return
quad
}
}
This diff is collapsed.
Click to expand it.
src/getters.js
+
2
−
2
View file @
b789c935
...
...
@@ -26,7 +26,7 @@ export const getStore = createSelector(
export
const
getNodeIds
=
createSelector
(
getStore
,
(
store
)
=>
{
return
store
.
find
(
null
,
lod
.
rdf
.
type
)
return
store
.
find
(
null
,
lod
.
rdf
.
type
,
null
,
null
)
.
map
((
quad
)
=>
quad
.
subject
)
}
)
...
...
@@ -39,7 +39,7 @@ export const getNodes = createSelector(
let
nodes
=
{}
nodeIds
.
forEach
((
nodeId
)
=>
{
let
node
=
{}
store
.
find
(
nodeId
).
forEach
((
quad
)
=>
{
store
.
find
(
nodeId
,
null
,
null
,
null
).
forEach
((
quad
)
=>
{
if
(
node
[
quad
.
predicate
]
==
null
)
{
node
[
quad
.
predicate
]
=
[]
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment