Christian Bay created JENA-1415:
-----------------------------------

             Summary: ConversionException for individuals
                 Key: JENA-1415
                 URL: https://issues.apache.org/jira/browse/JENA-1415
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ, Jena
    Affects Versions: Jena 3.4.0
         Environment: Linux, Maven, Openllet Reasoner
            Reporter: Christian Bay
            Priority: Minor


Hey there,
I'm getting a _ConversionException_ when converting a resource to an individual 
by using _as_. In another bugreport 
[https://issues.apache.org/jira/browse/JENA-1380] this exception occured 
because of lacking OWL2 support. Is it something similiar here? Below is the 
relevant part of the OWL File: 
{code:xml}
    <!-- http://www8.cs.fau.de/research:cgm/schizophrenia#R_AcuteSchizophrenia 
-->

    <owl:NamedIndividual 
rdf:about="http://www8.cs.fau.de/research:cgm/schizophrenia#R_AcuteSchizophrenia";>
        <rdf:type 
rdf:resource="http://www8.cs.fau.de/research:cgm/schizophrenia#AcuteSchizophrenia"/>
    </owl:NamedIndividual>

{code}
The code snippet sets up a query on a OntModel which uses the Openllet 
reasoner. 
{code:java}
                private ArrayList<String> queryForRecommended(Query query){;
                OntDocumentManager mgr = new OntDocumentManager();

                //imports
                mgr.addAltEntry(Misc.STR_TIME,Misc.PATH_TIME);
                mgr.addAltEntry(Misc.STR_SCHIZO,Misc.PATH_SCHIZO);
                
                // Create OntModel
                OntModelSpec s = new 
OntModelSpec(PelletReasonerFactory.THE_SPEC);
                s.setDocumentManager(mgr);

                OntModel ontModel = ModelFactory.createOntologyModel(s);
                try{
                        ontModel.read(patient.getFile().toURI().toString());
                }catch(Exception e){
                        e.printStackTrace();
                        return null;
                }

                QueryExecution qe = QueryExecutionFactory.create(query, 
ontModel);

                ResultSet rs = qe.execSelect();

                ArrayList<String> result = new ArrayList<String>();

                while(rs.hasNext()){
                        QuerySolution qs = rs.next();
                        // ------- ERROR ---------
                        Individual in = 
qs.getResource("diag").as(Individual.class); 
                   
                        ExtendedIterator it = in.listOntClasses(true);

                        String className = "";
                        while(it.hasNext()){
                                className = it.next().toString();
                        }
                        result.add(className);
                }
                qe.close();
                return result;
        }
{code}
This is the error message I'm getting. The Jena Api mention the following: 'In 
order to be recognised as an individual, rather than a generic resource, at 
least one rdf:type statement' .
But a rdf:type statement does exist. I'm a bit clueless.
{code}
Exception in thread "main" org.apache.jena.ontology.ConversionException: Cannot 
convert node 
http://www8.cs.fau.de/research:cgm/schizophrenia#R_AcuteSchizophrenia to 
Individual
        at 
org.apache.jena.ontology.impl.IndividualImpl$1.wrap(IndividualImpl.java:61)
        at org.apache.jena.enhanced.EnhNode.convertTo(EnhNode.java:152)
        at org.apache.jena.enhanced.EnhNode.convertTo(EnhNode.java:31)
        at org.apache.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:62)
        at org.apache.jena.enhanced.EnhNode.as(EnhNode.java:107)
        at gui.OWLHandler.queryForRecommended(OWLHandler.java:655)
        [...]
{code}
It is worth mentioning that I'm refactoring this code and it worked quite well 
with the Jena version 2.1.0 and the Pellet Reasoner for Owlapiv3.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to