[VIVO-1755] - Better error handling when reasoner disabled (#137)
* Better error handling when reasoner disabled * Change reasoner error log message to debug * Extend reasoner status error handling * Improve reasoner error log message and extend to JenaAdminActions * Bump up log level for admin action to 'warn' and edit admin panel error message
This commit is contained in:
parent
7981d24da7
commit
edef9309ab
4 changed files with 57 additions and 33 deletions
|
@ -199,12 +199,17 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet {
|
|||
|
||||
String error = null;
|
||||
String explanation = null;
|
||||
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
|
||||
if (!status.isConsistent()) {
|
||||
error = "INCONSISTENT ONTOLOGY: reasoning halted.";
|
||||
explanation = status.getExplanation();
|
||||
} else if ( status.isInErrorState() ) {
|
||||
error = "An error occurred during reasoning. Reasoning has been halted. See error log for details.";
|
||||
try {
|
||||
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
|
||||
if (!status.isConsistent()) {
|
||||
error = "INCONSISTENT ONTOLOGY: reasoning halted.";
|
||||
explanation = status.getExplanation();
|
||||
} else if ( status.isInErrorState() ) {
|
||||
error = "An error occurred during reasoning. Reasoning has been halted. See error log for details.";
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
error = "The inferencing engine is disabled. Data entered manually may exhibit unexpected behavior prior to inferencing.";
|
||||
log.debug("Status of reasoner could not be determined. It is likely disabled.", e);
|
||||
}
|
||||
|
||||
if (error != null) {
|
||||
|
|
|
@ -192,29 +192,33 @@ public class JenaAdminActions extends BaseEditController {
|
|||
}
|
||||
|
||||
private void printRestrictions() {
|
||||
TBoxReasonerModule reasoner = ApplicationUtils.instance().getTBoxReasonerModule();
|
||||
for (Restriction rest : reasoner.listRestrictions() ) {
|
||||
if (rest.isAllValuesFromRestriction()) {
|
||||
log.trace("All values from: ");
|
||||
AllValuesFromRestriction avfr = rest.asAllValuesFromRestriction();
|
||||
Resource res = avfr.getAllValuesFrom();
|
||||
if (res.canAs(OntClass.class)) {
|
||||
OntClass resClass = res.as(OntClass.class);
|
||||
for (Resource inst : resClass.listInstances().toList() ) {
|
||||
log.trace(" -"+inst.getURI());
|
||||
}
|
||||
}
|
||||
} else if (rest.isSomeValuesFromRestriction()) {
|
||||
log.trace("Some values from: ");
|
||||
} else if (rest.isHasValueRestriction()) {
|
||||
log.trace("Has value: ");
|
||||
}
|
||||
log.trace("On property "+rest.getOnProperty().getURI());
|
||||
for (Resource inst : rest.listInstances().toList() ) {
|
||||
log.trace(" "+inst.getURI());
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
TBoxReasonerModule reasoner = ApplicationUtils.instance().getTBoxReasonerModule();
|
||||
for (Restriction rest : reasoner.listRestrictions() ) {
|
||||
if (rest.isAllValuesFromRestriction()) {
|
||||
log.trace("All values from: ");
|
||||
AllValuesFromRestriction avfr = rest.asAllValuesFromRestriction();
|
||||
Resource res = avfr.getAllValuesFrom();
|
||||
if (res.canAs(OntClass.class)) {
|
||||
OntClass resClass = res.as(OntClass.class);
|
||||
for (Resource inst : resClass.listInstances().toList() ) {
|
||||
log.trace(" -"+inst.getURI());
|
||||
}
|
||||
}
|
||||
} else if (rest.isSomeValuesFromRestriction()) {
|
||||
log.trace("Some values from: ");
|
||||
} else if (rest.isHasValueRestriction()) {
|
||||
log.trace("Has value: ");
|
||||
}
|
||||
log.trace("On property "+rest.getOnProperty().getURI());
|
||||
for (Resource inst : rest.listInstances().toList() ) {
|
||||
log.trace(" "+inst.getURI());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
log.warn("Status of reasoner could not be determined. It is likely disabled", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLongLiterals() {
|
||||
|
|
|
@ -360,8 +360,13 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
}
|
||||
|
||||
protected boolean reasoningAvailable() {
|
||||
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
|
||||
return status.isConsistent() && !status.isInErrorState();
|
||||
try {
|
||||
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
|
||||
return status.isConsistent() && !status.isInErrorState();
|
||||
} catch (IllegalStateException e) {
|
||||
log.debug("Status of reasoner could not be determined. It is likely disabled.", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String getRequiredDatatypeURI(Individual individual, DataProperty dataprop, List<String> vclassURIs) {
|
||||
|
|
|
@ -8,6 +8,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
|
@ -17,6 +20,8 @@ import edu.cornell.mannlib.vitro.webapp.modules.tboxreasoner.TBoxReasonerStatus;
|
|||
|
||||
public class IndividualsViaVClassOptions implements FieldOptions {
|
||||
|
||||
protected static final Log log = LogFactory.getLog(IndividualsViaVClassOptions.class.getName());
|
||||
|
||||
public static final String LEFT_BLANK = "";
|
||||
protected List<String> vclassURIs;
|
||||
protected String defaultOptionLabel;
|
||||
|
@ -102,8 +107,13 @@ public class IndividualsViaVClassOptions implements FieldOptions {
|
|||
}
|
||||
|
||||
protected boolean isReasoningAvailable(){
|
||||
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
|
||||
return status.isConsistent() && !status.isInErrorState();
|
||||
try {
|
||||
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
|
||||
return status.isConsistent() && !status.isInErrorState();
|
||||
} catch (IllegalStateException e) {
|
||||
log.debug("Status of reasoner could not be determined. It is likely disabled.", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, Individual> addWhenMissingInference( String classUri , WebappDaoFactory wDaoFact ){
|
||||
|
|
Loading…
Add table
Reference in a new issue