NIHVIVO-1714 made changes to have button for Recomputing Inferences
This commit is contained in:
parent
c69bc2d9fc
commit
0693506db0
1 changed files with 19 additions and 6 deletions
|
@ -24,6 +24,8 @@ public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
|
||||||
private static final Log log = LogFactory.getLog(
|
private static final Log log = LogFactory.getLog(
|
||||||
SimpleReasonerRecomputeController.class);
|
SimpleReasonerRecomputeController.class);
|
||||||
|
|
||||||
|
private static final String RECOMPUTE_INFERENCES_FTL = "recomputeInferences.ftl";
|
||||||
|
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
// Due to requiresLoginLevel(), we don't get here unless logged in as DBA
|
// Due to requiresLoginLevel(), we don't get here unless logged in as DBA
|
||||||
if (!LoginStatusBean.getBean(vreq)
|
if (!LoginStatusBean.getBean(vreq)
|
||||||
|
@ -40,13 +42,23 @@ public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
|
||||||
if (simpleReasoner == null) {
|
if (simpleReasoner == null) {
|
||||||
messageStr = "No SimpleReasoner has been set up.";
|
messageStr = "No SimpleReasoner has been set up.";
|
||||||
} else {
|
} else {
|
||||||
|
String signal = (String) vreq.getParameter("signal");
|
||||||
if (simpleReasoner.isRecomputing()) {
|
if (simpleReasoner.isRecomputing()) {
|
||||||
messageStr =
|
messageStr =
|
||||||
"The SimpleReasoner is currently in the process of " +
|
"The SimpleReasoner is currently in the process of " +
|
||||||
"recomputing inferences.";
|
"recomputing inferences.";
|
||||||
} else {
|
} else{
|
||||||
new Thread(new Recomputer(simpleReasoner)).start();
|
String restart = (String)getServletContext().getAttribute("restart");
|
||||||
messageStr = "Recomputation of inferences started";
|
if(restart == null || restart.equals("showButton") || signal == null){
|
||||||
|
body.put("link", "show");
|
||||||
|
messageStr = null;
|
||||||
|
getServletContext().setAttribute("restart", "yes");
|
||||||
|
}
|
||||||
|
else if(signal!=null && signal.equals("Recompute")){
|
||||||
|
new Thread(new Recomputer(simpleReasoner)).start();
|
||||||
|
messageStr = "Recomputation of inferences started";
|
||||||
|
getServletContext().setAttribute("restart", "showButton");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +67,13 @@ public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
|
||||||
body.put("errorMessage",
|
body.put("errorMessage",
|
||||||
"There was an error while recomputing inferences: " +
|
"There was an error while recomputing inferences: " +
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
return new ExceptionResponseValues(
|
return new ExceptionResponseValues(
|
||||||
Template.ERROR_MESSAGE.toString(), body, e);
|
RECOMPUTE_INFERENCES_FTL, body, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.put("message", messageStr);
|
body.put("message", messageStr);
|
||||||
return new TemplateResponseValues(Template.MESSAGE.toString(), body);
|
body.put("redirecturl",vreq.getContextPath()+"/RecomputeInferences");
|
||||||
|
return new TemplateResponseValues(RECOMPUTE_INFERENCES_FTL, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Recomputer implements Runnable {
|
private class Recomputer implements Runnable {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue