I forgot to mention that this is happening during a Write Transaction on the Dataset, in case that is important.
Devlin On Wed, Aug 13, 2014 at 9:19 AM, Devlin Junker <[email protected]> wrote: > Hi, > > I am having a little bit of trouble implementing the TDB store for my Jena > Ontologies. I have been able to solve most of the issues that I've come > across, but I have become frustrated with the view request functions that > the Ontology objects define. > > I am trying to get a list of all of the restrictions that define a certain > OntClass, but while I am looping through all of the superclasses for the > class I receive a ConcurrentModificationException when calling the > is[Restriction, DatatypeProperty, and SomeValuesFromRestriction] calls. > > Apparently it is happening when finding the triple on the graph that would > define it as the certain view type. The exception is thrown on the > iterator.hasNext in GraphBase.containsByFind(). > > The application I am running is only single threaded (I think, it is in a > JUnit Test Case) so I don't think any other modifications should actually > be happening to the Dataset while I am checking against the View Type. > > I've included the important code below and highlighted the area where the > exception is thrown. > > Thanks for any help you can offer, > Devlin > > List<OntClass> supers = jenaClass.listSuperClasses().toList(); > > for(int index = 0; index < supers.size(); index++){ > OntClass cls = supers.get(index); > if(cls.isRestriction()){ > Restriction r = cls.asRestriction(); > String valueId = ""; > OntProperty prop = r.getOnProperty(); > Resource restrictionValue; > > if(r.isAllValuesFromRestriction()){ > restrictionValue = r.asAllValuesFromRestriction().getAllValuesFrom(); > }else if(r.isSomeValuesFromRestriction()){ > restrictionValue = r.asSomeValuesFromRestriction().getSomeValuesFrom(); > }else{ > // TODO: Implement Cardinality Restrictions > throw new RuntimeException("Unexpected Restriction Type"); > } > if(prop.isDatatypeProperty()){ > // TODO: More DataTypes > if(restrictionValue.equals(XSD.xint) || > restrictionValue.equals(XSD.integer)){ > valueId = "xsd:integer"; > }else if(restrictionValue.equals(XSD.xstring)){ > valueId = "xsd:string"; > }else if(restrictionValue.equals(XSD.xdouble)){ > valueId = "xsd:double"; > }else if(restrictionValue.equals(XSD.dateTime)){ > valueId = "xsd:dateTime"; > }else{ > throw new RuntimeException("Unrecognized DataType: > "+restrictionValue.toString()); > } > }else{ > valueId = getIdentifier(restrictionValue.getURI()); > } > try{ > if(r.isAllValuesFromRestriction()){ > JSONArray restriction = rest.optJSONArray(getIdentifier(prop.getURI())); > if(restriction == null || !restriction.toString().contains(valueId)){ > rest.append(getIdentifier(prop.getURI()), valueId); > } > }else if(r.isSomeValuesFromRestriction()){ > JSONArray requirement = req.optJSONArray(getIdentifier(prop.getURI())); > // TODO: HACK (For some reason during update I am getting duplicate of the > some value restrictions) > if(requirement == null || !requirement.toString().contains(valueId)){ > req.append(getIdentifier(prop.getURI()), valueId); > } > }else{ > // TODO: Implement Cardinality Restrictions > throw new RuntimeException("Unexpected Restriction Type"); > } > }catch(JSONException e){ > throw new RuntimeException("Error Creating JSON Object for Property " + > prop); > } > } > } >
