The code that I tried to write like the following :
-----
.......
OntModel m = ModelFactory.createOntologyModel();
m.read(input_filename);
DatatypeProperty dp = m.getDatatypeProperty(URI+"usd");
ExtendedIterator<Restriction> i = m.listRestrictions();
while (i.hasNext()){
Restriction r = i.next();
if (r.onProperty(dp) && r.isMaxCardinalityRestriction()){
com.hp.hpl.jena.rdf.model.Property opt = r.getOnProperty();
r.removeOnProperty(opt);
}
}
.......
-----
I tried to list all of the restriction, and then get the restriction that
applied to some certain property which is the URI+usd datatypeProperty. I could
get the MaxCardinality int by using the following script :
r.asMaxCardinalityRestriction().getMaxCardinality()
but I cannot remove the restriction using the removeOnProperty method, since it
always produce an error.
And the error looks like :
-----
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:567)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:471)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.util.ConcurrentModificationException
com.hp.hpl.jena.reasoner.rulesys.impl.LPTopGoalIterator.checkCME(LPTopGoalIterator.java:205)
com.hp.hpl.jena.reasoner.rulesys.impl.LPTopGoalIterator.hasNext(LPTopGoalIterator.java:180)
com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:64)
com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:64)
com.hp.hpl.jena.util.iterator.UniqueExtendedIterator.hasNext(UniqueExtendedIterator.java:69)
com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:64)
com.hp.hpl.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:43)
com.hp.hpl.jena.util.iterator.Map1Iterator.hasNext(Map1Iterator.java:38)
com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:64)
com.hp.hpl.jena.util.iterator.UniqueExtendedIterator.hasNext(UniqueExtendedIterator.java:69)
org.apache.jsp.test_jsp._jspService(test_jsp.java:140)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
-----
Once again, the part of the OWL file is as below :
<owl:Class rdf:ID="priceType">
<rdfs:subClassOf>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<owl:Restriction>
<owl:minCardinality
rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>1</owl:minCardinality>
<owl:onProperty>
<owl:DatatypeProperty rdf:ID="usd"/>
</owl:onProperty>
</owl:Restriction>
<owl:Restriction>
<owl:maxCardinality
rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>1</owl:maxCardinality>
<owl:onProperty rdf:resource="#usd"/>
</owl:Restriction>
<owl:Restriction>
<owl:minCardinality
rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>1</owl:minCardinality>
<owl:onProperty>
<owl:DatatypeProperty rdf:ID="aud"/>
</owl:onProperty>
</owl:Restriction>
<owl:Restriction>
<owl:maxCardinality
rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>1</owl:maxCardinality>
<owl:onProperty rdf:resource="#aud"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</rdfs:subClassOf>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>
------
Any help will be very appreciated. Thank you.
Dhomas Hatta Fudholi
PhD Candidate, Department of Computer Science and Computer Engineering
La Trobe University, Victoria 3086, Australia
________________________________________
From: Ian Dickinson [[email protected]]
Sent: Wednesday, June 06, 2012 5:08 AM
To: [email protected]
Subject: Re: [ASK] How to remove restriction using Jena?
On 05/06/12 12:34, DHOMAS HATTA FUDHOLI wrote:
> Hi All,
>
> I have something bothering in my mind in case of Jena. I need to
> remove restriction in the OWL file using Jena, but I couldn't figure
> how it could be done?
>
> ..........
>
> The thing is, I want to remove all restriction in the priceType class
> shown above. I have tried the removeOnProperty() method but It always
> result an error in the Tomcat.
It might help if you showed us the error. And the code. Otherwise, all
we can say is "it sounds like something has gone wrong".
Ian