I ran into this same problem two weeks ago. Joshua Taylor provided me with an 
answer, which I have included below. I ended up writing code similar to the 
following, where I passed a Resource object (OntModel.getResource(classURI)) 
representing the class to the method.

private long listProperties(Resource resource){
      StmtIterator iter = omodel.listStatements(resource, (Property)null, 
(RDFNode)null);
      while( iter.hasNext() ){
            Statement stmt = iter.next();
            Property property = stmt.getPredicate();
            String pname = property.getLocalName();
      }
}




-----Original Message-----
From: Joshua TAYLOR [mailto:[email protected]]
Sent: Tuesday, April 23, 2013 3:11 PM
To: [email protected]
Subject: Re: OntClass.listDeclaredProperties



On Tue, Apr 23, 2013 at 2:45 PM, David Jordan 
<[email protected]<mailto:[email protected]>> wrote:

> When I call listDeclaredProperties with a direct parameter value of false, I 
> get a list of properties associated with a class. But when I pass a value of 
> true, I don't get any values, yet there are properties directly associated 
> with the class. I do run this with a reasoner, using OWL_MEM_MICRO_RULE_INF. 
> I am using the latest TDB release. Any idea why they are not being returned?



Until now, I hadn't looked closely enough at the doc to know what

listDeclaredProperties was supposed to return.   It returns an

iterator over "properties associated with a frame-like view of this class", but 
I wasn't sure what "associated with" meant there.  Looking at the 
implementation in OntClassImpl, a property is associated with a class if class 
is one of the property's domains.  Is that the same meaning of "associated with 
a class" that you're operating under?  (I ask this not because your question 
suggested any misunderstanding, but because I, not having used 
listDeclaredProperties, assumed it might return properties in restrictions on 
classes and the like, and that doesn't appear to the be the case.)



//JT



--

Joshua Taylor, http://www.cs.rpi.edu/~tayloj/


From: Michael Trosin [mailto:[email protected]]
Sent: Tuesday, May 07, 2013 3:31 PM
To: [email protected]
Subject: Query declared properties returns too much

Hi,
I am quite new to mailing-lists, so sorry if this is not the way, how I should 
start a "topic".
I have the attached ontology and I'm trying to list declared properties of the 
class "Dataset" via:
OntClass ontclass = mOntModel.getOntClass(namespace + "#Dataset");
ExtendedIterator<OntProperty> ei = ontclass.listDeclaredProperties();
Doing it this way I get much properties, which actually aren't properties from 
dataset (hasDataAnalysis, hasPublishing, ...). Loading it with direct = true 
gives me the correct properties. So far so good, the problem is, that I get now 
wrong results when using:

OntClass ontclass = mOntModel.getOntClass(namespace + "#LifecycleResource");
ExtendedIterator<OntProperty> ei = ontclass.listDeclaredProperties(true);
Now the only property is "hasKey" (missing hasName, hasTimestamp, ...).
Is the ontology wrong defined? Or do I miss anything else?
I fixed one class and the other is no broken. I have no idea, what the issue 
could be.
For any ideas many thanks in advice.
Best regards,
 Michael

Reply via email to