Inserting self defined object properties












0















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 querrying 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.










share|improve this question

























  • The class Resource provides all the methods you need, e.g. addProperty, addLiteral etc. - Javadoc or the Apache Jena doc is always your friend

    – AKSW
    Jan 2 at 14:28











  • @AKSW thanks for the response! I tried your suggestion, but the addProperty requires a property instance, which I created with the resourceFactory with namespace "" and for example localName ns + "Skill#SkillName. But i get an error that a required component is missing in the scheme

    – Bram Kelchtermans
    Jan 2 at 15:49













  • Can you please add the code that doesn't work to the question? It's easier for me to reproduce resp. find the mistake. Note, it has to be a proper URL, please also show the String you're passing to the resource factory.

    – AKSW
    Jan 2 at 16:01













  • @AKSW Done, thanks for your time!

    – Bram Kelchtermans
    Jan 2 at 16:04











  • Ok, so why ResourceFactory.createProperty("", ns + "Skill#SkillName"); ? The frist argument is supposed to be the namespace, you just pass "" . Look at the Javadoc again: createProperty(String namespace, String localName) - so, shouldn't it createProperty(ns, "Skill#SkillName") ?

    – AKSW
    Jan 2 at 16:37


















0















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 querrying 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.










share|improve this question

























  • The class Resource provides all the methods you need, e.g. addProperty, addLiteral etc. - Javadoc or the Apache Jena doc is always your friend

    – AKSW
    Jan 2 at 14:28











  • @AKSW thanks for the response! I tried your suggestion, but the addProperty requires a property instance, which I created with the resourceFactory with namespace "" and for example localName ns + "Skill#SkillName. But i get an error that a required component is missing in the scheme

    – Bram Kelchtermans
    Jan 2 at 15:49













  • Can you please add the code that doesn't work to the question? It's easier for me to reproduce resp. find the mistake. Note, it has to be a proper URL, please also show the String you're passing to the resource factory.

    – AKSW
    Jan 2 at 16:01













  • @AKSW Done, thanks for your time!

    – Bram Kelchtermans
    Jan 2 at 16:04











  • Ok, so why ResourceFactory.createProperty("", ns + "Skill#SkillName"); ? The frist argument is supposed to be the namespace, you just pass "" . Look at the Javadoc again: createProperty(String namespace, String localName) - so, shouldn't it createProperty(ns, "Skill#SkillName") ?

    – AKSW
    Jan 2 at 16:37
















0












0








0








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 querrying 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.










share|improve this question
















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 querrying 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.







java rdf jena owl foaf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 16:38







Bram Kelchtermans

















asked Jan 2 at 14:17









Bram KelchtermansBram Kelchtermans

42




42













  • The class Resource provides all the methods you need, e.g. addProperty, addLiteral etc. - Javadoc or the Apache Jena doc is always your friend

    – AKSW
    Jan 2 at 14:28











  • @AKSW thanks for the response! I tried your suggestion, but the addProperty requires a property instance, which I created with the resourceFactory with namespace "" and for example localName ns + "Skill#SkillName. But i get an error that a required component is missing in the scheme

    – Bram Kelchtermans
    Jan 2 at 15:49













  • Can you please add the code that doesn't work to the question? It's easier for me to reproduce resp. find the mistake. Note, it has to be a proper URL, please also show the String you're passing to the resource factory.

    – AKSW
    Jan 2 at 16:01













  • @AKSW Done, thanks for your time!

    – Bram Kelchtermans
    Jan 2 at 16:04











  • Ok, so why ResourceFactory.createProperty("", ns + "Skill#SkillName"); ? The frist argument is supposed to be the namespace, you just pass "" . Look at the Javadoc again: createProperty(String namespace, String localName) - so, shouldn't it createProperty(ns, "Skill#SkillName") ?

    – AKSW
    Jan 2 at 16:37





















  • The class Resource provides all the methods you need, e.g. addProperty, addLiteral etc. - Javadoc or the Apache Jena doc is always your friend

    – AKSW
    Jan 2 at 14:28











  • @AKSW thanks for the response! I tried your suggestion, but the addProperty requires a property instance, which I created with the resourceFactory with namespace "" and for example localName ns + "Skill#SkillName. But i get an error that a required component is missing in the scheme

    – Bram Kelchtermans
    Jan 2 at 15:49













  • Can you please add the code that doesn't work to the question? It's easier for me to reproduce resp. find the mistake. Note, it has to be a proper URL, please also show the String you're passing to the resource factory.

    – AKSW
    Jan 2 at 16:01













  • @AKSW Done, thanks for your time!

    – Bram Kelchtermans
    Jan 2 at 16:04











  • Ok, so why ResourceFactory.createProperty("", ns + "Skill#SkillName"); ? The frist argument is supposed to be the namespace, you just pass "" . Look at the Javadoc again: createProperty(String namespace, String localName) - so, shouldn't it createProperty(ns, "Skill#SkillName") ?

    – AKSW
    Jan 2 at 16:37



















The class Resource provides all the methods you need, e.g. addProperty, addLiteral etc. - Javadoc or the Apache Jena doc is always your friend

– AKSW
Jan 2 at 14:28





The class Resource provides all the methods you need, e.g. addProperty, addLiteral etc. - Javadoc or the Apache Jena doc is always your friend

– AKSW
Jan 2 at 14:28













@AKSW thanks for the response! I tried your suggestion, but the addProperty requires a property instance, which I created with the resourceFactory with namespace "" and for example localName ns + "Skill#SkillName. But i get an error that a required component is missing in the scheme

– Bram Kelchtermans
Jan 2 at 15:49







@AKSW thanks for the response! I tried your suggestion, but the addProperty requires a property instance, which I created with the resourceFactory with namespace "" and for example localName ns + "Skill#SkillName. But i get an error that a required component is missing in the scheme

– Bram Kelchtermans
Jan 2 at 15:49















Can you please add the code that doesn't work to the question? It's easier for me to reproduce resp. find the mistake. Note, it has to be a proper URL, please also show the String you're passing to the resource factory.

– AKSW
Jan 2 at 16:01







Can you please add the code that doesn't work to the question? It's easier for me to reproduce resp. find the mistake. Note, it has to be a proper URL, please also show the String you're passing to the resource factory.

– AKSW
Jan 2 at 16:01















@AKSW Done, thanks for your time!

– Bram Kelchtermans
Jan 2 at 16:04





@AKSW Done, thanks for your time!

– Bram Kelchtermans
Jan 2 at 16:04













Ok, so why ResourceFactory.createProperty("", ns + "Skill#SkillName"); ? The frist argument is supposed to be the namespace, you just pass "" . Look at the Javadoc again: createProperty(String namespace, String localName) - so, shouldn't it createProperty(ns, "Skill#SkillName") ?

– AKSW
Jan 2 at 16:37







Ok, so why ResourceFactory.createProperty("", ns + "Skill#SkillName"); ? The frist argument is supposed to be the namespace, you just pass "" . Look at the Javadoc again: createProperty(String namespace, String localName) - so, shouldn't it createProperty(ns, "Skill#SkillName") ?

– AKSW
Jan 2 at 16:37














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007937%2finserting-self-defined-object-properties%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007937%2finserting-self-defined-object-properties%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith