Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix RDF and RDFS term IRIs #1010

Merged
merged 1 commit into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## Unreleased

- Fix RDF and RDFS term IRIs.

## 1.1.0 2023/10/01

- Add the ability to retrieve all the RDF:type values for any vocab term.
Expand Down
6 changes: 3 additions & 3 deletions src/VocabTerm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ describe("VocabTerm tests", () => {
});

it("should handle rdf:type of Class", () => {
const RDF_CLASS = rdfFactory.namedNode(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#Class",
const RDFS_CLASS = rdfFactory.namedNode(
"http://www.w3.org/2000/01/rdf-schema#Class",
);
const myTerm = buildBasicTerm(
"http://some.vocab#myTerm",
Expand All @@ -637,7 +637,7 @@ describe("VocabTerm tests", () => {
);

expect(myTerm.isClass).toBe(false);
myTerm.addType(RDF_CLASS);
myTerm.addType(RDFS_CLASS);
expect(myTerm.isClass).toBe(true);
});

Expand Down
20 changes: 10 additions & 10 deletions src/VocabTerm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const DEFAULT_LOCALE = "en";
// We need an instance of an RDF Factory to instantiate a Named Node, but we
// only want to create instances of these RDF types if we are checking for the
//
let LAZY_TYPE_RDF_CLASS: NamedNode | undefined = undefined;
let LAZY_TYPE_RDFS_CLASS: NamedNode | undefined = undefined;
let LAZY_TYPE_OWL_CLASS: NamedNode | undefined = undefined;

let LAZY_TYPE_RDFS_PROPERTY: NamedNode | undefined = undefined;
let LAZY_TYPE_RDF_PROPERTY: NamedNode | undefined = undefined;
let LAZY_TYPE_OWL_DATATYPE_PROPERTY: NamedNode | undefined = undefined;
let LAZY_TYPE_OWL_OBJECT_PROPERTY: NamedNode | undefined = undefined;
let LAZY_TYPE_OWL_ANNOTATION_PROPERTY: NamedNode | undefined = undefined;
Expand Down Expand Up @@ -266,8 +266,8 @@ class VocabTerm implements NamedNode {
}

createNamedNodeConstantsClass(): void {
LAZY_TYPE_RDF_CLASS = this.rdfFactory.namedNode(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#Class",
LAZY_TYPE_RDFS_CLASS = this.rdfFactory.namedNode(
"http://www.w3.org/2000/01/rdf-schema#Class",
);

LAZY_TYPE_OWL_CLASS = this.rdfFactory.namedNode(
Expand All @@ -276,8 +276,8 @@ class VocabTerm implements NamedNode {
}

createNamedNodeConstantsProperty(): void {
LAZY_TYPE_RDFS_PROPERTY = this.rdfFactory.namedNode(
"http://www.w3.org/2000/01/rdf-schema#Property",
LAZY_TYPE_RDF_PROPERTY = this.rdfFactory.namedNode(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#Property",
);
LAZY_TYPE_OWL_DATATYPE_PROPERTY = this.rdfFactory.namedNode(
"http://www.w3.org/2002/07/owl#Property",
Expand All @@ -303,23 +303,23 @@ class VocabTerm implements NamedNode {
}

get isClass(): boolean {
if (!LAZY_TYPE_RDF_CLASS) {
if (!LAZY_TYPE_RDFS_CLASS) {
this.createNamedNodeConstantsClass();
}

return (
(this._type?.has(LAZY_TYPE_RDF_CLASS!) ||
(this._type?.has(LAZY_TYPE_RDFS_CLASS!) ||
this._type?.has(LAZY_TYPE_OWL_CLASS!)) !== undefined
);
}

get isProperty(): boolean {
if (!LAZY_TYPE_RDFS_PROPERTY) {
if (!LAZY_TYPE_RDF_PROPERTY) {
this.createNamedNodeConstantsProperty();
}

return (
(this._type?.has(LAZY_TYPE_RDFS_PROPERTY!) ||
(this._type?.has(LAZY_TYPE_RDF_PROPERTY!) ||
this._type?.has(LAZY_TYPE_OWL_OBJECT_PROPERTY!) ||
this._type?.has(LAZY_TYPE_OWL_DATATYPE_PROPERTY!) ||
this._type?.has(LAZY_TYPE_OWL_ANNOTATION_PROPERTY!) ||
Expand Down