ResIterator it1 = repair.listSubjectsWithProperty( EYE.cardinalityFailure );
while( it1.hasNext() )
{
Resource curr = it1.nextResource();
RDFNode type = repair.listObjectsOfProperty( curr, EYE.onType ).nextNode();
RDFNode prop = repair.listObjectsOfProperty( curr, EYE.onProperty ).nextNode();
RDFNode b = repair.listObjectsOfProperty( curr, EYE.cardinality ).nextNode();
RDFNode maxCardR = null;
RDFNode minCardR = null;
try
{
maxCardR = repair.listObjectsOfProperty( repair.createResource( b.asNode().getBlankNodeId() ), EYE.max ).nextNode();
}
catch (NoSuchElementException e) {}
finally
{
try
{
minCardR = repair.listObjectsOfProperty( repair.createResource( b.asNode().getBlankNodeId() ), EYE.min ).nextNode();
}
catch (NoSuchElementException e) {}
if ( maxCardR == null ) // Set these equal if the Eyeball report didn't specify
maxCardR = minCardR; // (see below - this *shouldn't* cause an issue - send me
else if ( minCardR == null )// a test case if it does ;o) )
minCardR = maxCardR;
}
RDFNode numValsR = repair.listObjectsOfProperty( curr, EYE.numValues ).nextNode();
int maxCard = strToInt( maxCardR.asNode().getLiteralLexicalForm() );
int numVals = strToInt( numValsR.asNode().getLiteralLexicalForm() );
NodeIterator it1b = m.listObjectsOfProperty( m.createResource( type.asNode().getURI() ), RDFS.subClassOf );
while (it1b.hasNext() )
{
b = it1b.nextNode();
try
{
if ( b.isAnon() )
{
if ( m.listObjectsOfProperty( m.createResource( b.asNode().getBlankNodeId() ), OWL.onProperty ).nextNode().equals( prop ) )
break;
}
else
if ( m.listObjectsOfProperty( m.createResource( b.asNode().getURI() ), OWL.onProperty ).nextNode().equals( prop ) )
break;
}
catch (java.util.NoSuchElementException e)
{ // Not all statements returned are going to match the search above;
} // don't complain / warn about it!
}
// This looks misleading, but it will not be called if numVals > maxCard and owl:maxCardinality is not specified in the model!
if ( numVals > maxCard )
{ // Increase owl:maxCardinality as needed, unless we can remove some invalid type declarations...
// Get the rdfs:members of this failure's eye:values eye:Set
List<String> types = new ArrayList<String>();
List<Integer> typeCount = new ArrayList<Integer>();
NodeIterator it1c = repair.listObjectsOfProperty( repair.createResource( repair.listObjectsOfProperty( curr, EYE.values ).nextNode().asNode().getBlankNodeId() ), RDFS.member);
String defaultURI = "http://www.w3.org/2001/XMLSchema#String"; // This will be used later too (config file it??)
while ( it1c.hasNext() )
{
RDFNode member = it1c.nextNode();
String uri = member.asNode().getLiteralDatatypeURI();
if ( uri == null )
uri = defaultURI; // Default datatype URI
if ( types.contains( uri ) )
{
int idx = types.lastIndexOf( uri );