use of org.apache.jena.ontology.Individual in project jena by apache.
the class schemagen method writeOntIndividuals.
/** Write individuals as ontology terms */
protected void writeOntIndividuals() {
String template = m_options.hasIndividualTemplateOption() ? m_options.getIndividualTemplateOption() : DEFAULT_INDIVIDUAL_TEMPLATE;
for (Iterator<? extends RDFNode> i = selectIndividuals(); i.hasNext(); ) {
Individual ind = ((Resource) i.next()).as(Individual.class);
// do we have a local class resource
Resource cls = ind.getOntClass();
if (cls == null) {
cls = OWL.Thing;
}
String varName = m_resourcesToNames.get(cls);
String valType = (varName != null) ? varName : "M_MODEL.createClass( \"" + cls.getURI() + "\" )";
// push the individuals type onto the stack
addReplacementPattern("valtype", valType);
writeValue(ind, template, "Individual", "createIndividual", "_INSTANCE");
pop(1);
}
}
use of org.apache.jena.ontology.Individual in project ORCID-Source by ORCID.
the class RDFMessageBodyWriter method describeResearcherUrls.
private void describeResearcherUrls(ResearcherUrls researcherUrls, Individual person, OntModel m) {
if (researcherUrls == null || researcherUrls.getResearcherUrl() == null) {
return;
}
for (ResearcherUrl url : researcherUrls.getResearcherUrl()) {
Individual page = m.createIndividual(url.getUrl().getValue(), null);
String urlName = getUrlName(url);
if (isHomePage(urlName)) {
person.addProperty(FOAF.homepage, page);
} else if (isFoaf(urlName)) {
// TODO: What if we want to link to the URL of the other FOAF
// *Profile*?
// Note: We don't dear here to do owl:sameAs or
// prov:specializationOf as we don't know the extent of the
// other FOAF profile - we'll
// suffice to say it's an alternate view of the same person
person.addProperty(PROV.alternateOf, page);
page.addRDFType(FOAF.Person);
page.addRDFType(PROV.Person);
person.addSeeAlso(page);
} else if (isWebID(urlName)) {
person.addSameAs(page);
} else {
// It's some other foaf:page which might not be about
// this person
person.addProperty(FOAF.page, page);
}
}
}
use of org.apache.jena.ontology.Individual in project ORCID-Source by ORCID.
the class RDFMessageBodyWriter method describeError.
protected void describeError(ErrorDesc errorDesc, OntModel m) {
String error = errorDesc.getContent();
Individual root = m.createIndividual(m.createResource());
root.setLabel("Error", EN);
root.setComment(error, EN);
}
use of org.apache.jena.ontology.Individual in project ORCID-Source by ORCID.
the class RDFMessageBodyWriter method describePerson.
private Individual describePerson(OrcidProfile orcidProfile, OntModel m) {
String orcidUri = orcidProfile.getOrcidIdentifier().getUri();
Individual person = m.createIndividual(orcidUri, FOAF.Person);
person.addRDFType(PROV.Person);
if (orcidProfile.getOrcidBio() == null) {
return person;
}
OrcidBio orcidBio = orcidProfile.getOrcidBio();
if (orcidBio == null) {
return person;
}
describePersonalDetails(orcidBio.getPersonalDetails(), person, m);
describeContactDetails(orcidBio.getContactDetails(), person, m);
describeBiography(orcidBio.getBiography(), person, m);
describeResearcherUrls(orcidBio.getResearcherUrls(), person, m);
return person;
}
Aggregations