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;
}
use of org.apache.jena.ontology.Individual in project ORCID-Source by ORCID.
the class RDFMessageBodyWriterV2 method describeContactDetails.
private void describeContactDetails(Person orcidPerson, Individual person, OntModel m) {
if (orcidPerson == null) {
return;
}
Emails emails = orcidPerson.getEmails();
if (emails != null) {
for (Email email : emails.getEmails()) {
if (email.isCurrent()) {
Individual mbox = m.createIndividual("mailto:" + email.getEmail(), null);
person.addProperty(FOAF.mbox, mbox);
}
}
}
Addresses addresses = orcidPerson.getAddresses();
Address addr = (addresses != null && addresses.getAddress().size() > 0) ? addresses.getAddress().get(0) : null;
if (addr != null) {
if (addr.getCountry() != null) {
String countryCode = addr.getCountry().getValue().name();
Individual position = m.createIndividual(Geonames.Feature);
position.addProperty(Geonames.countryCode, countryCode);
person.addProperty(FOAF.based_near, position);
Individual country = getCountry(countryCode);
if (country != null) {
country = addToModel(position.getOntModel(), country);
position.addProperty(Geonames.parentCountry, country);
}
// TODO: Include URI and (a) full name of country
// Potential source: geonames.org
// See https://gist.github.com/stain/7566375
}
}
}
Aggregations