NIHVIVO-3036 fixed lockup of system when adding superclass of class with many individuals
This commit is contained in:
parent
4fa16f31ac
commit
f46e4b46f0
2 changed files with 52 additions and 57 deletions
|
@ -30,9 +30,11 @@ public class Classes2ClassesDaoJena extends JenaBaseDao implements Classes2Class
|
|||
deleteClasses2Classes(c2c, getOntModelSelector().getTBoxModel());
|
||||
}
|
||||
|
||||
//TODO restore write locks once reasoner is able to handle these update asynchronously.
|
||||
|
||||
public void deleteClasses2Classes( Classes2Classes c2c, OntModel ontModel )
|
||||
{
|
||||
ontModel.enterCriticalSection(Lock.WRITE);
|
||||
// ontModel.enterCriticalSection(Lock.WRITE);
|
||||
getOntModel().getBaseModel().notifyEvent(new EditEvent(getWebappDaoFactory().getUserURI(),true));
|
||||
try {
|
||||
OntResource subclass = getOntClass(ontModel,c2c.getSubclassURI());
|
||||
|
@ -48,7 +50,7 @@ public class Classes2ClassesDaoJena extends JenaBaseDao implements Classes2Class
|
|||
}
|
||||
} finally {
|
||||
getOntModel().getBaseModel().notifyEvent(new EditEvent(getWebappDaoFactory().getUserURI(),false));
|
||||
ontModel.leaveCriticalSection();
|
||||
// ontModel.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +60,7 @@ public class Classes2ClassesDaoJena extends JenaBaseDao implements Classes2Class
|
|||
|
||||
public void insertNewClasses2Classes( Classes2Classes c2c, OntModel ontModel )
|
||||
{
|
||||
ontModel.enterCriticalSection(Lock.WRITE);
|
||||
// ontModel.enterCriticalSection(Lock.WRITE);
|
||||
getOntModel().getBaseModel().notifyEvent(new EditEvent(getWebappDaoFactory().getUserURI(),true));
|
||||
try {
|
||||
Resource subclass = ontModel.getResource(c2c.getSubclassURI());
|
||||
|
@ -68,7 +70,7 @@ public class Classes2ClassesDaoJena extends JenaBaseDao implements Classes2Class
|
|||
}
|
||||
} finally {
|
||||
getOntModel().getBaseModel().notifyEvent(new EditEvent(getWebappDaoFactory().getUserURI(),false));
|
||||
ontModel.leaveCriticalSection();
|
||||
// ontModel.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -602,35 +602,33 @@ public class SimpleReasoner extends StatementListener {
|
|||
* inferred model, assert that it is of type A.
|
||||
*/
|
||||
public void addedSubClass(OntClass subClass, OntClass superClass, Model inferenceModel) {
|
||||
|
||||
log.debug("subClass = " + subClass.getURI() + " superClass = " + superClass.getURI());
|
||||
|
||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||
inferenceModel.enterCriticalSection(Lock.WRITE);
|
||||
|
||||
OntModel unionModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
unionModel.addSubModel(aboxModel);
|
||||
unionModel.addSubModel(inferenceModel);
|
||||
List<Resource> subjectList = new ArrayList<Resource>();
|
||||
aboxModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
OntModel unionModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
unionModel.addSubModel(aboxModel);
|
||||
unionModel.addSubModel(inferenceModel);
|
||||
|
||||
StmtIterator iter = unionModel.listStatements((Resource) null, RDF.type, subClass);
|
||||
|
||||
while (iter.hasNext()) {
|
||||
|
||||
Statement stmt = iter.next();
|
||||
Statement infStmt = ResourceFactory.createStatement(stmt.getSubject(), RDF.type, superClass);
|
||||
|
||||
inferenceModel.enterCriticalSection(Lock.WRITE);
|
||||
|
||||
if (!inferenceModel.contains(infStmt)) {
|
||||
inferenceModel.add(infStmt);
|
||||
setMostSpecificTypes(infStmt.getSubject(), inferenceModel, new HashSet<String>());
|
||||
}
|
||||
}
|
||||
subjectList.add(stmt.getSubject());
|
||||
}
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
inferenceModel.leaveCriticalSection();
|
||||
}
|
||||
for (Resource subject : subjectList) {
|
||||
Statement infStmt = ResourceFactory.createStatement(subject, RDF.type, superClass);
|
||||
inferenceModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
if (!inferenceModel.contains(infStmt)) {
|
||||
inferenceModel.add(infStmt);
|
||||
setMostSpecificTypes(subject, inferenceModel, new HashSet<String>());
|
||||
}
|
||||
} finally {
|
||||
inferenceModel.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -641,38 +639,33 @@ public class SimpleReasoner extends StatementListener {
|
|||
* of A (including A itself)
|
||||
*/
|
||||
public void removedSubClass(OntClass subClass, OntClass superClass, Model inferenceModel) {
|
||||
|
||||
log.debug("subClass = " + subClass.getURI() + ". superClass = " + superClass.getURI());
|
||||
|
||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||
inferenceModel.enterCriticalSection(Lock.WRITE);
|
||||
|
||||
try {
|
||||
OntModel unionModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
unionModel.addSubModel(aboxModel);
|
||||
unionModel.addSubModel(inferenceModel);
|
||||
|
||||
StmtIterator iter = unionModel.listStatements((Resource) null, RDF.type, subClass);
|
||||
|
||||
while (iter.hasNext()) {
|
||||
|
||||
Statement stmt = iter.next();
|
||||
Resource ind = stmt.getSubject();
|
||||
|
||||
if (entailedType(ind,superClass)) continue;
|
||||
|
||||
Statement infStmt = ResourceFactory.createStatement(ind, RDF.type, superClass);
|
||||
|
||||
inferenceModel.enterCriticalSection(Lock.WRITE);
|
||||
|
||||
if (inferenceModel.contains(infStmt)) {
|
||||
inferenceModel.remove(infStmt);
|
||||
setMostSpecificTypes(infStmt.getSubject(), inferenceModel, new HashSet<String>());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
inferenceModel.leaveCriticalSection();
|
||||
OntModel unionModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
unionModel.addSubModel(aboxModel);
|
||||
unionModel.addSubModel(inferenceModel);
|
||||
List<Resource> subjectList = new ArrayList<Resource>();
|
||||
aboxModel.enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
StmtIterator iter = unionModel.listStatements((Resource) null, RDF.type, subClass);
|
||||
while (iter.hasNext()) {
|
||||
Statement stmt = iter.next();
|
||||
subjectList.add(stmt.getSubject());
|
||||
}
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
for (Resource ind : subjectList) {
|
||||
if (entailedType(ind,superClass)) continue;
|
||||
Statement infStmt = ResourceFactory.createStatement(ind, RDF.type, superClass);
|
||||
inferenceModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
if (inferenceModel.contains(infStmt)) {
|
||||
inferenceModel.remove(infStmt);
|
||||
setMostSpecificTypes(infStmt.getSubject(), inferenceModel, new HashSet<String>());
|
||||
}
|
||||
} finally {
|
||||
inferenceModel.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1414,4 +1407,4 @@ public class SimpleReasoner extends StatementListener {
|
|||
"] [object = " + (statement.getObject().isLiteral() ? ((Literal)statement.getObject()).getLexicalForm() + " (Literal)"
|
||||
: ((Resource)statement.getObject()).getURI() + " (Resource)") + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue