Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
fix: improve prefixes handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Oct 28, 2019
1 parent 7e43101 commit e3206c7
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 64 deletions.
1 change: 1 addition & 0 deletions components/proposal/ClassForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
Add "<em>{{ clss['label'] }}</em>" to the proposal
</button>
</div>

<div class="column is-6">
<!-- <button
class="button is-dark-info is-pulled-right subform-cancel">
Expand Down
2 changes: 2 additions & 0 deletions components/proposal/PropertyForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@
<label class="checkbox">
<input
type="checkbox"
:disabled="disabled"
v-model.lazy="prop['isDeprecated']">
Deprecate Property
</label>
</div>
</div>
</div>

<div class="column">
<div class="field long-description">
<label class="label">Long Description (optional)</label>
Expand Down
9 changes: 8 additions & 1 deletion components/proposal/ProposalPropertiesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
:href="$rebaseIRI(range.value)"
rel="noopener noreferrer"
target="_blank">
{{ term(range.value) }}
{{ label(range) }}
</a>
</li>
</ul>
Expand Down Expand Up @@ -183,6 +183,13 @@ export default {
},
methods: {
term,
label (aTerm) {
const label = this.$store.getters['graph/ontology'].match(aTerm, this.$termIRI.label).toArray()[0]
if (!label) {
return this.$unPrefix(aTerm.value)
}
return term(label)
},
reselectDomain (index) {
this.$emit('reselectDomain', index)
},
Expand Down
103 changes: 52 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@rdfjs/serializer-ntriples": "^1.0.1",
"@rdfjs/to-ntriples": "^1.0.1",
"apicache": "^1.4.0",
"apollo-cache-inmemory": "^1.5.0",
"apollo-client": "^2.5.0",
"apollo-cache-inmemory": "^1.5.1",
"apollo-client": "^2.5.1",
"apollo-link": "^1.2.8",
"apollo-link-http": "^1.5.11",
"babel-plugin-dynamic-import-node": "^2.2.0",
Expand Down
39 changes: 29 additions & 10 deletions plugins/libs/rdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,39 @@ export default ({ app, store }, inject) => {
inject('buildSearchIndex', buildSearchIndex)
inject('buildTree', buildTree)
inject('findClassProperties', findClassProperties)
inject('unPrefix', unPrefix)

const createExternalType = ([iri, label]) =>
rdf.quad(rdf.namedNode(iri), termIRI.label, rdf.literal(label))

const externalTypes = [
['http://www.w3.org/2001/XMLSchema#boolean', 'Boolean (xsd:boolean)'],
['http://www.w3.org/2001/XMLSchema#date', 'Date (xsd:date)'],
['http://www.w3.org/2001/XMLSchema#dateTime', 'Date and time (xsd:dateTime)'],
['http://www.w3.org/2001/XMLSchema#double', 'Double (xsd:double)'],
['http://www.w3.org/2001/XMLSchema#decimal', 'Decimal (xsd:decimal)'],
['http://www.w3.org/2001/XMLSchema#int', 'Integer (xsd:int)'],
['http://www.w3.org/2001/XMLSchema#string', 'String (xsd:string)'],
['http://www.w3.org/2001/XMLSchema#time', 'Time (xsd:time)']
].map(createExternalType)
const prefixes = [{
prefix: 'http://www.w3.org/2001/XMLSchema#',
short: 'xsd:'
}, {
prefix: 'http://www.w3.org/2000/01/rdf-schema#',
short: 'rdfs:'
}]

const allExternalTypes = [
['http://www.w3.org/2000/01/rdf-schema#literal', 'rdfs:literal'],
['http://www.w3.org/2001/XMLSchema#boolean', 'xsd:boolean'],
['http://www.w3.org/2001/XMLSchema#date', 'xsd:date'],
['http://www.w3.org/2001/XMLSchema#dateTime', 'xsd:dateTime'],
['http://www.w3.org/2001/XMLSchema#double', 'xsd:double'],
['http://www.w3.org/2001/XMLSchema#decimal', 'xsd:decimal'],
['http://www.w3.org/2001/XMLSchema#int', 'xsd:int'],
['http://www.w3.org/2001/XMLSchema#string', 'xsd:string'],
['http://www.w3.org/2001/XMLSchema#time', 'xsd:time']
]
const externalTypes = allExternalTypes.map(createExternalType)

function unPrefix (iri) {
const found = prefixes.find(p => iri.startsWith(p.prefix))
if (found) {
return iri.replace(new RegExp(`^${found.prefix}`), found.short)
}
return iri
}

function toObject (domain, dataset) {
let label = dataset.match(domain.subject, termIRI.label).toArray()
Expand Down

0 comments on commit e3206c7

Please sign in to comment.