For a school project, we have to use RDF and OWL to create a vacancy/applicant service. We are writing this service with Spring and Apache Jena. This service will contain persons that have certain skills and vacancies of companies that require some skills. We've created the ontologies, but we can't find out how to create a skill and link it to a person.
First we tried to make an hasSkill objectproperty directly to a foaf:person with the following code:
<owl:ObjectProperty rdf:about="foaf#hasSkill">
<owl:domain owl:class="foaf#person" />
<owl:range owl:class="#Skill" />
</owl:ObjectProperty>
We tried inserting these skills using SparQL, but we couldn't find out how to link the created skill to an existing user. Another method we tried is accessing the property by code.
Resource user = userRepository.getUserResource(userID);
Property skill = model.createProperty("Skill");
Where the first line gets the user's resource by querying it with SparQL.
The code defining the Skill-ontology:
<owl:Class owl:name="Skill">
<owl:Annotation>
<owl:Label>Skill</owl:Label>
</owl:Annotation>
</owl:Class>
<owl:ObjectProperty rdf:about="http://localhost:8080/ontologies/Skill#SkillName">
<owl:domain owl:class="Skill" />
<owl:range owl:class="rdfs#literal"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://localhost:8080/ontologies/Skill#CompetencyLevel">
<owl:domain owl:class="Skill" />
<owl:range owl:class="rdfs#literal" />
</owl:ObjectProperty>
The code defining our applicant ontology:
<owl:Class owl:name="Applicant">
<owl:Annotation>
<owl:Label>Applicant</owl:Label>
</owl:Annotation>
</owl:Class>
<owl:ObjectProperty rdf:about="http://localhost:8080/ontologies/Applicant#Person">
<owl:domain owl:class="Applicant" />
<owl:range owl:class="foaf#person" />
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://localhost:8080/ontologies/Degree#StudyField">
<owl:domain owl:class="Applicant" />
<owl:range owl:class="#Skill" />
</owl:ObjectProperty>
What we want to do is that an existing user can add skills to their profile. These skills then can be used to match vacancies to the applicant.
After the suggestion of AKSW, I tried to use the Resource
class of Jena:
Property name = ResourceFactory.createProperty("", ns + "Skill#SkillName");
Property competencyLvl = ResourceFactory.createProperty("", ns + "Skill#CompetencyLevel");
Resource r = model.getModel().createResource("Skill")
.addProperty(name, skillDetail.getSkillName())
.addProperty(competencyLvl, skillDetail.getCompetencyLevel());
model.writeChanges();
The namespace (ns) is equal to "http://localhost:8080/ontologies/" But this gives me the error that a required component is missing in the scheme.