Skip to content

Commit

Permalink
Add seperate file for rdf rdf-data
Browse files Browse the repository at this point in the history
Add a file for default shape and default resource used in FormDemo.vue.
Add import and usage.
  • Loading branch information
splattater committed Aug 19, 2024
1 parent f45db39 commit 36c289a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 41 deletions.
31 changes: 31 additions & 0 deletions src/helpers/rdf-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict'


// The default NodeShape used in FormDemo.vue
const defaultShape = `@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org#> .
ex:DefaultShape
a sh:NodeShape, rdf:Class ;
sh:property [
sh:name 'class' ;
sh:path rdf:type ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
sh:property [
sh:name 'label' ;
sh:path rdfs:label ;
sh:maxCount 1 ;
] .`

// The default resource used in FormDemo.vue
const defaultData = `@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://example.org/Example> rdf:type rdf:Class ;
<http://www.w3.org/2000/01/rdf-schema#label> 'Example resource'. `

export { defaultShape, defaultData }
45 changes: 4 additions & 41 deletions src/views/FormDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { useSelectionStore } from '../stores/selection'
import { Store, StreamParser, Parser, Writer } from 'n3'
import { registerPlugin } from '@ulb-darmstadt/shacl-form'
import { getShapeQuery4Target, getShapeQuery4Instance } from '../helpers/queries'
import { defaultShape, defaultData } from '../helpers/rdf-data'
import { quadStreamToStore, quadStreamToString } from '../helpers/rdf-parse'
import { Splitpanes, Pane } from 'splitpanes'
// import { LeafletPlugin } from '@ulb-darmstadt/shacl-form/plugins/leaflet.js'
Expand Down Expand Up @@ -66,29 +67,8 @@ export default {
data () {
return {
dataModel: {},
dataTurtle: `@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://example.org/Example> rdf:type rdf:Class ;
<http://www.w3.org/2000/01/rdf-schema#label> 'Example resource'. `,
shapeTurtle: `@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org#> .
ex:DefaultShape
a sh:NodeShape, rdf:Class ;
sh:property [
sh:name 'class' ;
sh:path rdf:type ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
sh:property [
sh:name 'label' ;
sh:path rdfs:label ;
sh:maxCount 1 ;
] .`,
dataTurtle: defaultData,
shapeTurtle: defaultShape,
subject: rdf.namedNode(''),
}
},
Expand Down Expand Up @@ -131,24 +111,7 @@ ex:DefaultShape
if (shapeData.length < 1) {
console.log('Form: Use default shape')
shapeTurtle = `@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org#> .
ex:DefaultShape
a sh:NodeShape, rdfs:Class ;
sh:property [
sh:name 'class' ;
sh:path rdf:type ;
sh:minCount 1 ;
sh:maxCount 1 ;
] ;
sh:property [
sh:name 'label' ;
sh:path rdfs:label ;
sh:maxCount 1 ;
] .`
shapeTurtle = defaultShape
} else {
console.log('Form: Use found shape')
let data_string = ""
Expand Down

0 comments on commit 36c289a

Please sign in to comment.