Skip to content

Commit

Permalink
Refactors literal input.
Browse files Browse the repository at this point in the history
closes #3011
  • Loading branch information
justinlittman committed Sep 27, 2021
1 parent e44dc31 commit 6d9076e
Show file tree
Hide file tree
Showing 43 changed files with 1,869 additions and 1,517 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ ENV HONEYBADGER_API_KEY=$HONEYBADGER_API_KEY
# Set environment variables from the build args
ENV INDEX_URL ${INDEX_URL}

# Everything that isn't in .dockerignore ships
COPY --chown=circleci:circleci . .

RUN mkdir dist
RUN mkdir node_modules
COPY --chown=circleci:circleci package.json .
COPY --chown=circleci:circleci package-lock.json .

# Install dependencies
RUN npm install --no-optional

# Everything that isn't in .dockerignore ships
COPY --chown=circleci:circleci . .

# Build the app *within* the container because environment variables are fixed at build-time
RUN npm run build

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,12 @@ The following are only in the resource subject (that is, the base subject).
-> property: {<property>},
literal: <literal>,
lang: <language for literal>,
-> langLabel: <label for language>,
uri: <uri>,
label: <label for uri>,
valueSubjectKey: <key for subject for a nested resource>,
-> valueSubject: {<subject>}
-> index: <1 based index of the value (relative to siblings)>
-> index: <1 based index of the value (relative to siblings)>
rootResourceKey: <key of root resource that this property is descendant of>
rootPropertyKey: <key of root property that this subject is part of>
}
Expand Down
89 changes: 89 additions & 0 deletions __tests__/GraphBuilder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,95 @@ _:c14n3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://id.loc.gov/ont
expect(new GraphBuilder(resource).graph.toCanonical()).toMatch(rdf)
})

it("builds a graph ignoring empty literals", () => {
const resource = {
subjectTemplate: {
id: "resourceTemplate:testing:uber1",
class: "http://id.loc.gov/ontologies/bibframe/Uber1",
},
properties: [
{
propertyTemplate: {
uri: "http://id.loc.gov/ontologies/bibframe/uber/template1/property2",
},
values: [
{
literal: "literal1",
lang: "eng",
uri: null,
// Value references its property.
property: {
propertyTemplate: {
type: "literal",
},
},
},
// Empty
{
literal: "",
uri: null,
property: {
propertyTemplate: {
type: "literal",
},
},
},
],
},
],
}

const rdf = `<> <http://id.loc.gov/ontologies/bibframe/uber/template1/property2> "literal1"@eng .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "resourceTemplate:testing:uber1" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://id.loc.gov/ontologies/bibframe/Uber1> .`
expect(new GraphBuilder(resource).graph.toCanonical()).toMatch(rdf)
})

it("builds a graph ignoring empty URIs", () => {
const resource = {
subjectTemplate: {
id: "resourceTemplate:testing:uber1",
class: "http://id.loc.gov/ontologies/bibframe/Uber1",
},
properties: [
{
propertyTemplate: {
uri: "http://id.loc.gov/ontologies/bibframe/uber/template1/property8",
},
values: [
// With label
{
uri: "http://sinopia.io/uri1",
label: "URI1",
// Value references its property.
property: {
propertyTemplate: {
type: "uri",
},
},
},
// Empty
{
uri: "",
label: null,
property: {
propertyTemplate: {
type: "uri",
},
},
},
],
},
],
}

const rdf = `<> <http://id.loc.gov/ontologies/bibframe/uber/template1/property8> <http://sinopia.io/uri1> .
<> <http://sinopia.io/vocabulary/hasResourceTemplate> "resourceTemplate:testing:uber1" .
<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://id.loc.gov/ontologies/bibframe/Uber1> .
<http://sinopia.io/uri1> <http://www.w3.org/2000/01/rdf-schema#label> "URI1" .`
expect(new GraphBuilder(resource).graph.toCanonical()).toMatch(rdf)
})

it("builds a graph for suppressible nested resource with uri", () => {
const resource = {
subjectTemplate: {
Expand Down
Loading

0 comments on commit 6d9076e

Please sign in to comment.