NIHVIVO-1752 bugix for backend object property editing (merge from nihvivo 1.2 maint branch)
This commit is contained in:
parent
df8628b47a
commit
f6676d58b7
3 changed files with 107 additions and 28 deletions
|
@ -0,0 +1,73 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
||||||
|
|
||||||
|
public class SDBSetupController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(
|
||||||
|
SimpleReasonerRecomputeController.class);
|
||||||
|
|
||||||
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
// Due to requiresLoginLevel(), we don't get here unless logged in as DBA
|
||||||
|
if (!LoginStatusBean.getBean(vreq)
|
||||||
|
.isLoggedInAtLeast(LoginStatusBean.DBA)) {
|
||||||
|
return new RedirectResponseValues(UrlBuilder.getUrl(Route.LOGIN));
|
||||||
|
}
|
||||||
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
String messageStr = "";
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (false) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (false) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
new Thread(new SDBSetupRunner()).start();
|
||||||
|
messageStr = "SDB setup started";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error setting up SDB store", e);
|
||||||
|
body.put("errorMessage",
|
||||||
|
"Error setting up SDB store: " +
|
||||||
|
e.getMessage());
|
||||||
|
return new ExceptionResponseValues(
|
||||||
|
Template.ERROR_MESSAGE.toString(), body, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.put("message", messageStr);
|
||||||
|
return new TemplateResponseValues(Template.MESSAGE.toString(), body);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SDBSetupRunner implements Runnable {
|
||||||
|
|
||||||
|
private SimpleReasoner simpleReasoner;
|
||||||
|
|
||||||
|
public SDBSetupRunner() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -52,10 +52,10 @@ public class ObjectPropertyStatementDaoSDB extends
|
||||||
" ?o <" + RDFS.label.getURI() + "> ?oLabel . \n" +
|
" ?o <" + RDFS.label.getURI() + "> ?oLabel . \n" +
|
||||||
" ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker \n" +
|
" ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker \n" +
|
||||||
"} WHERE { GRAPH ?g { \n" +
|
"} WHERE { GRAPH ?g { \n" +
|
||||||
" <" + entity.getURI() + "> ?p ?o . \n" +
|
" <" + entity.getURI() + "> ?p ?o \n" +
|
||||||
" ?o a ?oType \n" +
|
" OPTIONAL { GRAPH ?h { ?o a ?oType } } \n" +
|
||||||
" OPTIONAL { ?o <" + RDFS.label.getURI() + "> ?oLabel } \n" +
|
" OPTIONAL { GRAPH ?i { ?o <" + RDFS.label.getURI() + "> ?oLabel } } \n" +
|
||||||
" OPTIONAL { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } \n" +
|
" OPTIONAL { GRAPH ?j { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } } \n" +
|
||||||
"} }";
|
"} }";
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
Model m = null;
|
Model m = null;
|
||||||
|
@ -85,7 +85,6 @@ public class ObjectPropertyStatementDaoSDB extends
|
||||||
try {
|
try {
|
||||||
while (propIt.hasNext()) {
|
while (propIt.hasNext()) {
|
||||||
Statement st = (Statement) propIt.next();
|
Statement st = (Statement) propIt.next();
|
||||||
|
|
||||||
if (st.getObject().isResource() && !(NONUSER_NAMESPACES.contains(st.getPredicate().getNameSpace()))) {
|
if (st.getObject().isResource() && !(NONUSER_NAMESPACES.contains(st.getPredicate().getNameSpace()))) {
|
||||||
try {
|
try {
|
||||||
ObjectPropertyStatement objPropertyStmt = new ObjectPropertyStatementImpl();
|
ObjectPropertyStatement objPropertyStmt = new ObjectPropertyStatementImpl();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class PropertyInstanceDaoJena extends JenaBaseDao implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI) {
|
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI) {
|
||||||
deleteObjectPropertyStatement(subjectURI, propertyURI, objectURI, getOntModelSelector().getABoxModel());
|
deleteObjectPropertyStatement(subjectURI, propertyURI, objectURI, getOntModelSelector().getFullModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI, OntModel ontModel) {
|
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI, OntModel ontModel) {
|
||||||
|
@ -316,14 +316,18 @@ public class PropertyInstanceDaoJena extends JenaBaseDao implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public int insertProp(PropertyInstanceIface prop) {
|
public int insertProp(PropertyInstanceIface prop) {
|
||||||
return insertProp(prop, getOntModelSelector().getABoxModel());
|
return insertProp(prop, getOntModelSelector());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int insertProp(PropertyInstanceIface prop, OntModel ontModel) {
|
public int insertProp(PropertyInstanceIface prop, OntModelSelector oms) {
|
||||||
|
OntModel ontModel = oms.getABoxModel();
|
||||||
|
OntModel tboxModel = oms.getTBoxModel();
|
||||||
ontModel.enterCriticalSection(Lock.WRITE);
|
ontModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
try {
|
||||||
|
tboxModel.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
Resource subjRes = ontModel.getResource(prop.getSubjectEntURI());
|
Resource subjRes = ontModel.getResource(prop.getSubjectEntURI());
|
||||||
OntProperty pred = ontModel.getOntProperty(prop.getPropertyURI());
|
OntProperty pred = tboxModel.getOntProperty(prop.getPropertyURI());
|
||||||
Resource objRes = ontModel.getResource(prop.getObjectEntURI());
|
Resource objRes = ontModel.getResource(prop.getObjectEntURI());
|
||||||
if ( (subjRes != null) && (pred != null) && (objRes != null) ) {
|
if ( (subjRes != null) && (pred != null) && (objRes != null) ) {
|
||||||
getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,prop.getSubjectEntURI()));
|
getOntModel().getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,prop.getSubjectEntURI()));
|
||||||
|
@ -345,6 +349,9 @@ public class PropertyInstanceDaoJena extends JenaBaseDao implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
} finally {
|
||||||
|
tboxModel.leaveCriticalSection();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
ontModel.leaveCriticalSection();
|
ontModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue