Search in sources :

Example 6 with Individual

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);
    }
}
Also used : Individual(org.apache.jena.ontology.Individual)

Example 7 with Individual

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);
        }
    }
}
Also used : Individual(org.apache.jena.ontology.Individual) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl)

Example 8 with Individual

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);
}
Also used : Individual(org.apache.jena.ontology.Individual)

Example 9 with Individual

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;
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Individual(org.apache.jena.ontology.Individual)

Aggregations

Individual (org.apache.jena.ontology.Individual)9 OntModel (org.apache.jena.ontology.OntModel)3 Test (org.junit.Test)2 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 MediaType (javax.ws.rs.core.MediaType)1 BaseTest (org.apache.jena.atlas.junit.BaseTest)1 ObjectProperty (org.apache.jena.ontology.ObjectProperty)1 Literal (org.apache.jena.rdf.model.Literal)1 Model (org.apache.jena.rdf.model.Model)1 Address (org.orcid.jaxb.model.message.Address)1 Email (org.orcid.jaxb.model.message.Email)1 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)1 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)1