Each class works by itself but not when I try to add multiple classes.
Any suggestions?
const hasCityContentSchema = () => {
console.log(’# checking CityContent schema’)
// set database to use to MyDemo1
WOQL.db(‘MyDemo1’)
// check if a class called ‘scm:Object’ exists
// and is a sub of class ‘system:Document’
WOQL.query(Q
.quad(‘v:Class’, ‘type’, ‘owl:Class’, ‘schema’)
.sub(‘system:Document’, ‘v:Class’)
.eq(‘v:Class’, ‘scm:CityContent’)
)
.then(response => {
if (response.bindings.length === 0) {
// add the schema for class ‘scm:City_Content’
console.log(’# creating City Content schema’)
WOQL.query(Q
.doctype(“CityContent”).label(“City_Content”)
.description(‘An Object of type City Content’)
.property(“id”, “xsd:integer”).label(“City Content Id”).cardinality(1)
.property(“content_id”, “xsd:integer”).label(“Content Id”).cardinality(1)
.property(“city_id”, “xsd:integer”).label(“City Id”).cardinality(1)
.property(“name”, “xsd:string”).label(“City Name”)
.and(
WOQL.query(Q
.doctype(“Person_Content”).label(“Person Content”)
.description(‘An Object of type Person Content’)
.property(“id”, “xsd:integer”).label(“Person Content Id”).cardinality(1)
.property(“content_id”, “xsd:integer”).label(“Content Id”).cardinality(1)
.property(“person_id”, “xsd:integer”).label(“Person Id”).cardinality(1)
.property(“first_name”, “xsd:string”).label(“First Name”)
.property(“last_name”, “xsd:string”).label(“Last Name”)
.property(“age”, “xsd:integer”).label(“Person Age”).cardinality(1)
))
).then(response => {
}).catch(error => console.log(‘add City Content Data error’, error))
} else {
console.log(’# Database CityContent schema already created’)
done()
}
})
.catch(error => console.log(‘CityContent error’, error))
}
const addPersonContentData = () => {
console.log(’# add personContent1 data 0’)
WOQL.query(Q
.add_triple(‘doc:personContent1’, ‘type’, ‘scm:PersonContent’)
.add_triple(‘doc:personContent1’, ‘id’, Q.literal(1, ‘xsd:integer’))
.add_triple(‘doc:personContent1’, ‘content_id’, Q.literal(2, ‘xsd:integer’))
.add_triple(‘doc:personContent1’, ‘person_id’, Q.literal(2, ‘xsd:integer’))
.add_triple(‘doc:personContent1’, ‘first_name’, Q.literal(‘Bob’, ‘xsd:string’))
.add_triple(‘doc:personContent1’, ‘last_name’, Q.literal(‘Kid’, ‘xsd:string’))
.add_triple(‘doc:personContent1’, ‘age’, Q.literal(21, ‘xsd:integer’))
.add_triple(‘doc:personContent1’, ‘city_id’, Q.literal(1, ‘xsd:integer’))
.comment(‘Add an PersonContent data 0’)
).then(() => {
console.log(’# add personContent2 data 1’)
WOQL.query(Q
.add_triple(‘doc:personContent2’, ‘type’, ‘scm:PersonContent’)
.add_triple(‘doc:personContent2’, ‘id’, Q.literal(2, ‘xsd:integer’))
.add_triple(‘doc:personContent2’, ‘content_id’, Q.literal(4, ‘xsd:integer’))
.add_triple(‘doc:personContent2’, ‘person_id’, Q.literal(4, ‘xsd:integer’))
.add_triple(‘doc:personContent2’, ‘first_name’, Q.literal(‘Kim’, ‘xsd:string’))
.add_triple(‘doc:personContent2’, ‘last_name’, Q.literal(‘Hugs’, ‘xsd:string’))
.add_triple(‘doc:personContent2’, ‘age’, Q.literal(21, ‘xsd:integer’))
.add_triple(‘doc:personContent2’, ‘city_id’, Q.literal(3, ‘xsd:integer’))
.comment(‘Add an PersonContent data 1’)
).then(() => {
}).catch(error => console.log(‘PersonContent Data 1 error’, error))
}).catch(error => console.log(‘PersonContent Data 0 error’, error))
}