setting the stage for some connection management improvements
This commit is contained in:
parent
f4186c3657
commit
a9e244a3ee
12 changed files with 309 additions and 135 deletions
|
@ -1312,9 +1312,6 @@ private String doRename(String oldNamespace,String newNamespace,HttpServletRespo
|
||||||
result = counter.toString() + " resources renamed";
|
result = counter.toString() + " resources renamed";
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
public void prepareSmush (VitroRequest vreq) {
|
|
||||||
String smushPropURI = vreq.getParameter("smushPropURI");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,14 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.fileupload.FileItem;
|
import org.apache.commons.fileupload.FileItem;
|
||||||
|
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -40,13 +43,14 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServ
|
||||||
|
|
||||||
public class RDFUploadController extends BaseEditController {
|
public class RDFUploadController extends BaseEditController {
|
||||||
|
|
||||||
private static int maxFileSizeInBytes = 1024 * 1024 * 2000; //2000mb
|
private static int maxFileSizeInBytes = 1024 * 1024 * 2000; //2000mb
|
||||||
private static FileItem fileStream=null;
|
private static FileItem fileStream=null;
|
||||||
private static final String INGEST_MENU_JSP = "/jenaIngest/ingestMenu.jsp";
|
private static final String INGEST_MENU_JSP = "/jenaIngest/ingestMenu.jsp";
|
||||||
private static final String LOAD_RDF_DATA_JSP = "/jenaIngest/loadRDFData.jsp";
|
private static final String LOAD_RDF_DATA_JSP = "/jenaIngest/loadRDFData.jsp";
|
||||||
|
|
||||||
public void doPost(HttpServletRequest rawRequest,
|
public void doPost(HttpServletRequest rawRequest,
|
||||||
HttpServletResponse response) throws ServletException, IOException {
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
FileUploadServletRequest req = FileUploadServletRequest.parseRequest(rawRequest,
|
FileUploadServletRequest req = FileUploadServletRequest.parseRequest(rawRequest,
|
||||||
maxFileSizeInBytes);
|
maxFileSizeInBytes);
|
||||||
if (req.hasFileUploadException()) {
|
if (req.hasFileUploadException()) {
|
||||||
|
@ -85,6 +89,10 @@ public class RDFUploadController extends BaseEditController {
|
||||||
|
|
||||||
boolean makeClassgroups = (request.getParameter("makeClassgroups") != null);
|
boolean makeClassgroups = (request.getParameter("makeClassgroups") != null);
|
||||||
|
|
||||||
|
// add directly to the ABox model without reading first into
|
||||||
|
// a temporary in-memory model
|
||||||
|
boolean directRead = ("directAddABox".equals(request.getParameter("mode")));
|
||||||
|
|
||||||
int[] portalArray = null;
|
int[] portalArray = null;
|
||||||
String individualCheckIn = request.getParameter("checkIndividualsIntoPortal");
|
String individualCheckIn = request.getParameter("checkIndividualsIntoPortal");
|
||||||
if (individualCheckIn != null) {
|
if (individualCheckIn != null) {
|
||||||
|
@ -108,14 +116,21 @@ public class RDFUploadController extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
String uploadDesc ="";
|
String uploadDesc ="";
|
||||||
|
|
||||||
OntModel tempModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel uploadModel = (directRead)
|
||||||
|
? getABoxModel(request.getSession(), getServletContext())
|
||||||
|
: ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
|
|
||||||
/* ********************* GET RDF by URL ********************** */
|
/* ********************* GET RDF by URL ********************** */
|
||||||
String RDFUrlStr = request.getParameter("rdfUrl");
|
String RDFUrlStr = request.getParameter("rdfUrl");
|
||||||
if (RDFUrlStr != null && RDFUrlStr.length() > 0) {
|
if (RDFUrlStr != null && RDFUrlStr.length() > 0) {
|
||||||
try {
|
try {
|
||||||
tempModel.read(RDFUrlStr, languageStr); // languageStr may be null and default would be RDF/XML
|
uploadModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
try {
|
||||||
|
uploadModel.read(RDFUrlStr, languageStr); // languageStr may be null and default would be RDF/XML
|
||||||
|
} finally {
|
||||||
|
uploadModel.leaveCriticalSection();
|
||||||
|
}
|
||||||
uploadDesc = verb + " RDF from " + RDFUrlStr;
|
uploadDesc = verb + " RDF from " + RDFUrlStr;
|
||||||
} catch (JenaException ex){
|
} catch (JenaException ex){
|
||||||
forwardToFileUploadError("Could not parse file to " + languageStr + ": " + ex.getMessage(), req, response);
|
forwardToFileUploadError("Could not parse file to " + languageStr + ": " + ex.getMessage(), req, response);
|
||||||
|
@ -129,7 +144,12 @@ public class RDFUploadController extends BaseEditController {
|
||||||
if( fileStreams.get("rdfStream") != null && fileStreams.get("rdfStream").size() > 0 ){
|
if( fileStreams.get("rdfStream") != null && fileStreams.get("rdfStream").size() > 0 ){
|
||||||
FileItem rdfStream = fileStreams.get("rdfStream").get(0);
|
FileItem rdfStream = fileStreams.get("rdfStream").get(0);
|
||||||
try {
|
try {
|
||||||
tempModel.read( rdfStream.getInputStream(), null, languageStr);
|
uploadModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
try {
|
||||||
|
uploadModel.read( rdfStream.getInputStream(), null, languageStr);
|
||||||
|
} finally {
|
||||||
|
uploadModel.leaveCriticalSection();
|
||||||
|
}
|
||||||
uploadDesc = verb + " RDF from file " + rdfStream.getName();
|
uploadDesc = verb + " RDF from file " + rdfStream.getName();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
forwardToFileUploadError("Could not read file: " + e.getLocalizedMessage(), req, response);
|
forwardToFileUploadError("Could not read file: " + e.getLocalizedMessage(), req, response);
|
||||||
|
@ -145,43 +165,31 @@ public class RDFUploadController extends BaseEditController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********** Do the model changes *********** */
|
/* ********** Do the model changes *********** */
|
||||||
long tboxstmtCount = 0L;
|
if( !directRead && uploadModel != null ){
|
||||||
long aboxstmtCount = 0L;
|
long tboxstmtCount = 0L;
|
||||||
if( tempModel != null ){
|
long aboxstmtCount = 0L;
|
||||||
|
|
||||||
JenaModelUtils xutil = new JenaModelUtils();
|
JenaModelUtils xutil = new JenaModelUtils();
|
||||||
OntModel tboxModel=null;
|
OntModel tboxModel = getTBoxModel(
|
||||||
OntModel aboxModel=null;
|
request.getSession(), getServletContext());
|
||||||
|
OntModel aboxModel = getABoxModel(
|
||||||
|
request.getSession(), getServletContext());
|
||||||
OntModel tboxChangeModel=null;
|
OntModel tboxChangeModel=null;
|
||||||
Model aboxChangeModel=null;
|
Model aboxChangeModel=null;
|
||||||
|
|
||||||
try {
|
|
||||||
tboxModel = ((OntModelSelector) request.getSession()
|
|
||||||
.getAttribute("baseOntModelSelector")).getTBoxModel();
|
|
||||||
aboxModel = ((OntModelSelector) request.getSession()
|
|
||||||
.getAttribute("baseOntModelSelector")).getABoxModel();
|
|
||||||
|
|
||||||
} catch (Exception e) {}
|
|
||||||
if (tboxModel==null) {
|
|
||||||
tboxModel = ((OntModelSelector) getServletContext()
|
|
||||||
.getAttribute("baseOntModelSelector")).getTBoxModel();
|
|
||||||
}
|
|
||||||
if (aboxModel==null) {
|
|
||||||
aboxModel = ((OntModelSelector) getServletContext()
|
|
||||||
.getAttribute("baseOntModelSelector")).getABoxModel();
|
|
||||||
}
|
|
||||||
if (tboxModel != null) {
|
if (tboxModel != null) {
|
||||||
tboxChangeModel = xutil.extractTBox(tempModel);
|
tboxChangeModel = xutil.extractTBox(uploadModel);
|
||||||
tboxstmtCount = operateOnModel(request.getFullWebappDaoFactory(), tboxModel,tboxChangeModel,remove,makeClassgroups,portalArray,loginBean.getUserURI());
|
tboxstmtCount = operateOnModel(request.getFullWebappDaoFactory(), tboxModel,tboxChangeModel,remove,makeClassgroups,portalArray,loginBean.getUserURI());
|
||||||
}
|
}
|
||||||
if (aboxModel != null) {
|
if (aboxModel != null) {
|
||||||
aboxChangeModel = tempModel.remove(tboxChangeModel);
|
aboxChangeModel = uploadModel.remove(tboxChangeModel);
|
||||||
aboxstmtCount = operateOnModel(request.getFullWebappDaoFactory(), aboxModel,aboxChangeModel,remove,makeClassgroups,portalArray,loginBean.getUserURI());
|
aboxstmtCount = operateOnModel(request.getFullWebappDaoFactory(), aboxModel,aboxChangeModel,remove,makeClassgroups,portalArray,loginBean.getUserURI());
|
||||||
}
|
}
|
||||||
|
request.setAttribute("uploadDesc", uploadDesc + ". " + verb + " " + (tboxstmtCount + aboxstmtCount) + " statements.");
|
||||||
|
} else {
|
||||||
|
request.setAttribute("uploadDesc", "RDF upload successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
request.setAttribute("uploadDesc", uploadDesc + ". " + verb + " " + (tboxstmtCount + aboxstmtCount) + " statements.");
|
|
||||||
|
|
||||||
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
|
||||||
request.setAttribute("bodyJsp","/templates/edit/specific/upload_rdf_result.jsp");
|
request.setAttribute("bodyJsp","/templates/edit/specific/upload_rdf_result.jsp");
|
||||||
|
@ -306,7 +314,33 @@ public class RDFUploadController extends BaseEditController {
|
||||||
ModelMaker myVjmm = (ModelMaker) request.getSession().getAttribute("vitroJenaModelMaker");
|
ModelMaker myVjmm = (ModelMaker) request.getSession().getAttribute("vitroJenaModelMaker");
|
||||||
myVjmm = (myVjmm == null) ? (ModelMaker) getServletContext().getAttribute("vitroJenaModelMaker") : myVjmm;
|
myVjmm = (myVjmm == null) ? (ModelMaker) getServletContext().getAttribute("vitroJenaModelMaker") : myVjmm;
|
||||||
return new VitroJenaSpecialModelMaker(myVjmm, request);
|
return new VitroJenaSpecialModelMaker(myVjmm, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OntModel getABoxModel(HttpSession session, ServletContext ctx) {
|
||||||
|
if (session != null
|
||||||
|
&& session.getAttribute("baseOntModelSelector")
|
||||||
|
instanceof OntModelSelector) {
|
||||||
|
return ((OntModelSelector)
|
||||||
|
session.getAttribute("baseOntModelSelector"))
|
||||||
|
.getABoxModel();
|
||||||
|
} else {
|
||||||
|
return ((OntModelSelector)
|
||||||
|
ctx.getAttribute("baseOntModelSelector")).getABoxModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private OntModel getTBoxModel(HttpSession session, ServletContext ctx) {
|
||||||
|
if (session != null
|
||||||
|
&& session.getAttribute("baseOntModelSelector")
|
||||||
|
instanceof OntModelSelector) {
|
||||||
|
return ((OntModelSelector)
|
||||||
|
session.getAttribute("baseOntModelSelector"))
|
||||||
|
.getTBoxModel();
|
||||||
|
} else {
|
||||||
|
return ((OntModelSelector)
|
||||||
|
ctx.getAttribute("baseOntModelSelector")).getTBoxModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(RDFUploadController.class.getName());
|
private static final Log log = LogFactory.getLog(RDFUploadController.class.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,11 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
public class DataPropertyStatementDaoSDB extends DataPropertyStatementDaoJena
|
public class DataPropertyStatementDaoSDB extends DataPropertyStatementDaoJena
|
||||||
implements DataPropertyStatementDao {
|
implements DataPropertyStatementDao {
|
||||||
|
|
||||||
private Dataset dataset;
|
private DatasetWrapperFactory dwf;
|
||||||
|
|
||||||
public DataPropertyStatementDaoSDB(Dataset dataset, WebappDaoFactoryJena wadf) {
|
public DataPropertyStatementDaoSDB(DatasetWrapperFactory datasetWrapperFactory, WebappDaoFactoryJena wadf) {
|
||||||
super (wadf);
|
super (wadf);
|
||||||
this.dataset = dataset;
|
this.dwf = datasetWrapperFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +58,16 @@ public class DataPropertyStatementDaoSDB extends DataPropertyStatementDaoJena
|
||||||
" <" + entity.getURI() + "> ?p ?o . \n" +
|
" <" + entity.getURI() + "> ?p ?o . \n" +
|
||||||
" FILTER(isLiteral(?o)) \n" +
|
" FILTER(isLiteral(?o)) \n" +
|
||||||
"} }" ;
|
"} }" ;
|
||||||
Model results = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
Model results = null;
|
||||||
|
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
try {
|
||||||
|
results = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
||||||
|
} finally {
|
||||||
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
|
}
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, results);
|
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, results);
|
||||||
ontModel.enterCriticalSection(Lock.READ);
|
ontModel.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
|
import com.hp.hpl.jena.sdb.sql.SDBConnection;
|
||||||
|
|
||||||
|
public class DatasetWrapper {
|
||||||
|
|
||||||
|
private SDBConnection conn;
|
||||||
|
private Dataset dataset;
|
||||||
|
private boolean closed = false;
|
||||||
|
|
||||||
|
public DatasetWrapper(Dataset dataset) {
|
||||||
|
this.dataset = dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dataset getDataset() {
|
||||||
|
if (!closed) {
|
||||||
|
return dataset;
|
||||||
|
} else throw new RuntimeException("No operations on a closed dataset");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (!closed) {
|
||||||
|
closed = true;
|
||||||
|
if (conn != null) {
|
||||||
|
dataset.close();
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
|
public interface DatasetWrapperFactory {
|
||||||
|
|
||||||
|
public DatasetWrapper getDatasetWrapper();
|
||||||
|
|
||||||
|
}
|
|
@ -41,26 +41,27 @@ import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
public class IndividualDaoSDB extends IndividualDaoJena {
|
public class IndividualDaoSDB extends IndividualDaoJena {
|
||||||
|
|
||||||
private Dataset dataset;
|
private DatasetWrapperFactory dwf;
|
||||||
private WebappDaoFactoryJena wadf;
|
private WebappDaoFactoryJena wadf;
|
||||||
|
|
||||||
public IndividualDaoSDB(Dataset dataset, WebappDaoFactoryJena wadf) {
|
public IndividualDaoSDB(DatasetWrapperFactory dwf, WebappDaoFactoryJena wadf) {
|
||||||
super(wadf);
|
super(wadf);
|
||||||
this.dataset = dataset;
|
this.dwf = dwf;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dataset getDataset() {
|
protected DatasetWrapper getDatasetWrapper() {
|
||||||
return this.dataset;
|
return dwf.getDatasetWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Individual makeIndividual(String individualURI) {
|
protected Individual makeIndividual(String individualURI) {
|
||||||
return new IndividualSDB2(individualURI, getDataset(), getWebappDaoFactory());
|
return new IndividualSDB(individualURI, this.dwf, getWebappDaoFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(IndividualDaoSDB.class.getName());
|
private static final Log log = LogFactory.getLog(IndividualDaoSDB.class.getName());
|
||||||
|
@ -90,36 +91,49 @@ public class IndividualDaoSDB extends IndividualDaoJena {
|
||||||
ents.addAll(getIndividualsByVClass(vc));
|
ents.addAll(getIndividualsByVClass(vc));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Model model;
|
Model model = null;
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
|
||||||
try {
|
try {
|
||||||
String query =
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
"CONSTRUCT " +
|
Dataset dataset = w.getDataset();
|
||||||
"{ ?ind <" + RDFS.label.getURI() + "> ?ooo. \n" +
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
"?ind a <" + theClass.getURI() + "> . \n" +
|
try {
|
||||||
"?ind <" + VitroVocabulary.MONIKER + "> ?moniker \n" +
|
String query =
|
||||||
"} WHERE " +
|
"CONSTRUCT " +
|
||||||
"{ GRAPH ?g { \n" +
|
"{ ?ind <" + RDFS.label.getURI() + "> ?ooo. \n" +
|
||||||
" ?ind a <" + theClass.getURI() + "> \n" +
|
"?ind a <" + theClass.getURI() + "> . \n" +
|
||||||
"} \n" +
|
"?ind <" + VitroVocabulary.MONIKER + "> ?moniker \n" +
|
||||||
"OPTIONAL { GRAPH ?h { ?ind <" + RDFS.label.getURI() + "> ?ooo } }\n" +
|
"} WHERE " +
|
||||||
"OPTIONAL { GRAPH ?i { ?ind <" + VitroVocabulary.MONIKER + "> ?moniker } } \n" +
|
"{ GRAPH ?g { \n" +
|
||||||
"}";
|
" ?ind a <" + theClass.getURI() + "> \n" +
|
||||||
model = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
"} \n" +
|
||||||
} finally {
|
"OPTIONAL { GRAPH ?h { ?ind <" + RDFS.label.getURI() + "> ?ooo } }\n" +
|
||||||
dataset.getLock().leaveCriticalSection();
|
"OPTIONAL { GRAPH ?i { ?ind <" + VitroVocabulary.MONIKER + "> ?moniker } } \n" +
|
||||||
}
|
"}";
|
||||||
ResIterator resIt = model.listSubjects();
|
model = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
||||||
try {
|
} finally {
|
||||||
while (resIt.hasNext()) {
|
dataset.getLock().leaveCriticalSection();
|
||||||
Resource ind = resIt.nextResource();
|
w.close();
|
||||||
if (!ind.isAnon()) {
|
}
|
||||||
ents.add(new IndividualSDB(ind.getURI(), dataset, getWebappDaoFactory(), model));
|
ResIterator resIt = model.listSubjects();
|
||||||
|
try {
|
||||||
|
while (resIt.hasNext()) {
|
||||||
|
Resource ind = resIt.nextResource();
|
||||||
|
if (!ind.isAnon()) {
|
||||||
|
//Individual indd = new IndividualImpl(ind.getURI());
|
||||||
|
//indd.setLocalName(ind.getLocalName());
|
||||||
|
//indd.setName(ind.getLocalName());
|
||||||
|
//ents.add(indd);
|
||||||
|
ents.add(new IndividualSDB(ind.getURI(), dataset, getWebappDaoFactory(), model));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
resIt.close();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
resIt.close();
|
if (model != null && !model.isClosed()) {
|
||||||
}
|
model.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -285,6 +299,9 @@ public class IndividualDaoSDB extends IndividualDaoJena {
|
||||||
|
|
||||||
|
|
||||||
Query q = QueryFactory.create(query);
|
Query q = QueryFactory.create(query);
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
QueryExecution qe = QueryExecutionFactory.create(q, dataset);
|
QueryExecution qe = QueryExecutionFactory.create(q, dataset);
|
||||||
try {
|
try {
|
||||||
ResultSet rs = qe.execSelect();
|
ResultSet rs = qe.execSelect();
|
||||||
|
@ -295,7 +312,9 @@ public class IndividualDaoSDB extends IndividualDaoJena {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
qe.close();
|
qe.close();
|
||||||
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// getOntModel().enterCriticalSection(Lock.READ);
|
// getOntModel().enterCriticalSection(Lock.READ);
|
||||||
|
|
|
@ -69,13 +69,13 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
private WebappDaoFactoryJena webappDaoFactory = null;
|
private WebappDaoFactoryJena webappDaoFactory = null;
|
||||||
private Float _searchBoostJena = null;
|
private Float _searchBoostJena = null;
|
||||||
private boolean retreivedNullRdfsLabel = false;
|
private boolean retreivedNullRdfsLabel = false;
|
||||||
private Dataset dataset = null;
|
private DatasetWrapperFactory dwf = null;
|
||||||
private String individualURI = null;
|
private String individualURI = null;
|
||||||
private Model model = null;
|
private Model model = null;
|
||||||
|
|
||||||
public IndividualSDB(String individualURI, Dataset dataset, WebappDaoFactoryJena wadf, Model initModel) {
|
public IndividualSDB(String individualURI, DatasetWrapperFactory datasetWrapperFactory, WebappDaoFactoryJena wadf, Model initModel) {
|
||||||
this.individualURI = individualURI;
|
this.individualURI = individualURI;
|
||||||
this.dataset = dataset;
|
this.dwf = datasetWrapperFactory;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
initModel.getLock().enterCriticalSection(Lock.READ);
|
initModel.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
@ -113,12 +113,14 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
this.webappDaoFactory = wadf;
|
this.webappDaoFactory = wadf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndividualSDB(String individualURI, Dataset dataset, WebappDaoFactoryJena wadf) {
|
public IndividualSDB(String individualURI, DatasetWrapperFactory datasetWrapperFactory, WebappDaoFactoryJena wadf) {
|
||||||
this.individualURI = individualURI;
|
this.individualURI = individualURI;
|
||||||
this.dataset = dataset;
|
this.dwf = datasetWrapperFactory;
|
||||||
|
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
try {
|
try {
|
||||||
this.dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
String getStatements =
|
String getStatements =
|
||||||
"CONSTRUCT " +
|
"CONSTRUCT " +
|
||||||
"{ <"+individualURI+"> <" + RDFS.label.getURI() + "> ?ooo. \n" +
|
"{ <"+individualURI+"> <" + RDFS.label.getURI() + "> ?ooo. \n" +
|
||||||
|
@ -133,7 +135,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
"}";
|
"}";
|
||||||
model = QueryExecutionFactory.create(QueryFactory.create(getStatements), dataset).execConstruct();
|
model = QueryExecutionFactory.create(QueryFactory.create(getStatements), dataset).execConstruct();
|
||||||
} finally {
|
} finally {
|
||||||
this.dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, model);
|
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, model);
|
||||||
|
@ -155,6 +158,10 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
this.webappDaoFactory = wadf;
|
this.webappDaoFactory = wadf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DatasetWrapper getDatasetWrapper() {
|
||||||
|
return this.dwf.getDatasetWrapper();
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (this.name != null) {
|
if (this.name != null) {
|
||||||
return name;
|
return name;
|
||||||
|
@ -249,10 +256,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#Flag1Value1Thing"
|
"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#Flag1Value1Thing"
|
||||||
*/
|
*/
|
||||||
public boolean doesFlag1Match(int flagBitMask) {
|
public boolean doesFlag1Match(int flagBitMask) {
|
||||||
Long [] numerics = FlagMathUtils.numeric2numerics(flagBitMask);
|
Long [] numerics = FlagMathUtils.numeric2numerics(flagBitMask);
|
||||||
this.dataset.getLock().enterCriticalSection(Lock.READ);
|
String Ask = null;
|
||||||
String Ask = null;
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try{
|
try{
|
||||||
for( Long numericPortal : numerics){
|
for( Long numericPortal : numerics){
|
||||||
int portalid = FlagMathUtils.numeric2Portalid(numericPortal);
|
int portalid = FlagMathUtils.numeric2Portalid(numericPortal);
|
||||||
|
@ -262,19 +270,19 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}finally{
|
}finally{
|
||||||
|
dataset.getLock().leaveCriticalSection();
|
||||||
this.dataset.getLock().leaveCriticalSection();
|
w.close();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doFlag1() {
|
private void doFlag1() {
|
||||||
|
|
||||||
String getObjects = null;
|
String getObjects = null;
|
||||||
|
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
|
||||||
Model tempModel = ModelFactory.createDefaultModel();
|
Model tempModel = ModelFactory.createDefaultModel();
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
ClosableIterator typeIt = null;
|
ClosableIterator typeIt = null;
|
||||||
int portalNumeric = 0;
|
int portalNumeric = 0;
|
||||||
|
@ -310,16 +318,19 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
} finally {
|
} finally {
|
||||||
tempModel.close();
|
tempModel.close();
|
||||||
ontModel.close();
|
ontModel.close();
|
||||||
this.dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void doFlag2() {
|
private void doFlag2() {
|
||||||
String getObjects = null;
|
String getObjects = null;
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
Model tempModel = ModelFactory.createDefaultModel();
|
||||||
Model tempModel = ModelFactory.createDefaultModel();
|
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
ClosableIterator typeIt=null;
|
ClosableIterator typeIt=null;
|
||||||
String flagSet = "";
|
String flagSet = "";
|
||||||
|
@ -352,7 +363,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
} finally {
|
} finally {
|
||||||
tempModel.close();
|
tempModel.close();
|
||||||
ontModel.close();
|
ontModel.close();
|
||||||
this.dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,7 +578,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
String getPropertyValue =
|
String getPropertyValue =
|
||||||
"SELECT ?value" +
|
"SELECT ?value" +
|
||||||
"WHERE { GRAPH ?g { <" + individualURI + ">" + webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT + "?value} }";
|
"WHERE { GRAPH ?g { <" + individualURI + ">" + webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT + "?value} }";
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try{
|
try{
|
||||||
try {
|
try {
|
||||||
|
@ -577,8 +590,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
}
|
}
|
||||||
return searchBoost;
|
return searchBoost;
|
||||||
}finally{
|
}finally{
|
||||||
|
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -646,10 +659,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doUrlAndAnchor() {
|
private void doUrlAndAnchor() {
|
||||||
|
Model tempModel = ModelFactory.createDefaultModel();
|
||||||
this.dataset.getLock().enterCriticalSection(Lock.READ);
|
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
Model tempModel = ModelFactory.createDefaultModel();
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
if (webappDaoFactory.getJenaBaseDao().PRIMARY_LINK != null) {
|
if (webappDaoFactory.getJenaBaseDao().PRIMARY_LINK != null) {
|
||||||
String listPropertyValues =
|
String listPropertyValues =
|
||||||
|
@ -685,7 +699,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
} finally {
|
} finally {
|
||||||
tempModel.close();
|
tempModel.close();
|
||||||
ontModel.close();
|
ontModel.close();
|
||||||
this.dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,12 +781,13 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<ObjectPropertyStatement> objectPropertyStatements = new ArrayList<ObjectPropertyStatement>();
|
List<ObjectPropertyStatement> objectPropertyStatements = new ArrayList<ObjectPropertyStatement>();
|
||||||
|
|
||||||
|
Model tempModel = ModelFactory.createDefaultModel();
|
||||||
|
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
Model tempModel = ModelFactory.createDefaultModel();
|
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String valuesOfProperty =
|
String valuesOfProperty =
|
||||||
"CONSTRUCT{<" + this.individualURI + "> <" + propertyURI + "> ?object}" +
|
"CONSTRUCT{<" + this.individualURI + "> <" + propertyURI + "> ?object}" +
|
||||||
"WHERE{ GRAPH ?g { <" + this.individualURI + "> <" + propertyURI + "> ?object} }";
|
"WHERE{ GRAPH ?g { <" + this.individualURI + "> <" + propertyURI + "> ?object} }";
|
||||||
|
@ -784,8 +800,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
if (!s.getSubject().canAs(OntResource.class) || !s.getObject().canAs(OntResource.class)) {
|
if (!s.getSubject().canAs(OntResource.class) || !s.getObject().canAs(OntResource.class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Individual subj = new IndividualSDB(((OntResource) s.getSubject().as(OntResource.class)).getURI(), dataset, webappDaoFactory);
|
Individual subj = new IndividualSDB(((OntResource) s.getSubject().as(OntResource.class)).getURI(), this.dwf, webappDaoFactory);
|
||||||
Individual obj = new IndividualSDB(((OntResource) s.getObject().as(OntResource.class)).getURI(), dataset, webappDaoFactory);
|
Individual obj = new IndividualSDB(((OntResource) s.getObject().as(OntResource.class)).getURI(), this.dwf, webappDaoFactory);
|
||||||
ObjectProperty op = webappDaoFactory.getObjectPropertyDao().getObjectPropertyByURI(s.getPredicate().getURI());
|
ObjectProperty op = webappDaoFactory.getObjectPropertyDao().getObjectPropertyByURI(s.getPredicate().getURI());
|
||||||
if (subj != null && obj != null && op != null) {
|
if (subj != null && obj != null && op != null) {
|
||||||
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
||||||
|
@ -802,6 +818,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
tempModel.close();
|
tempModel.close();
|
||||||
ontModel.close();
|
ontModel.close();
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
return objectPropertyStatements;
|
return objectPropertyStatements;
|
||||||
}
|
}
|
||||||
|
@ -813,6 +830,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
}
|
}
|
||||||
List<Individual> relatedIndividuals = new ArrayList<Individual>();
|
List<Individual> relatedIndividuals = new ArrayList<Individual>();
|
||||||
|
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
String valuesOfProperty =
|
String valuesOfProperty =
|
||||||
|
@ -825,11 +844,12 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
RDFNode value = result.get("object");
|
RDFNode value = result.get("object");
|
||||||
if (value.canAs(OntResource.class)) {
|
if (value.canAs(OntResource.class)) {
|
||||||
relatedIndividuals.add(
|
relatedIndividuals.add(
|
||||||
new IndividualSDB(((OntResource) value.as(OntResource.class)).getURI(), dataset, webappDaoFactory) );
|
new IndividualSDB(((OntResource) value.as(OntResource.class)).getURI(), this.dwf, webappDaoFactory) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
return relatedIndividuals;
|
return relatedIndividuals;
|
||||||
}
|
}
|
||||||
|
@ -839,7 +859,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
if (propertyURI == null) {
|
if (propertyURI == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
String valueOfProperty =
|
String valueOfProperty =
|
||||||
|
@ -849,12 +870,13 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
QuerySolution result = results.next();
|
QuerySolution result = results.next();
|
||||||
RDFNode value = result.get("object");
|
RDFNode value = result.get("object");
|
||||||
if (value != null && value.canAs(OntResource.class)) {
|
if (value != null && value.canAs(OntResource.class)) {
|
||||||
return new IndividualSDB(((OntResource) value.as(OntResource.class)).getURI(), dataset, webappDaoFactory);
|
return new IndividualSDB(((OntResource) value.as(OntResource.class)).getURI(), dwf, webappDaoFactory);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,13 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
public class ObjectPropertyStatementDaoSDB extends
|
public class ObjectPropertyStatementDaoSDB extends
|
||||||
ObjectPropertyStatementDaoJena implements ObjectPropertyStatementDao {
|
ObjectPropertyStatementDaoJena implements ObjectPropertyStatementDao {
|
||||||
|
|
||||||
private Dataset dataset;
|
private DatasetWrapperFactory dwf;
|
||||||
|
|
||||||
public ObjectPropertyStatementDaoSDB(Dataset dataset, WebappDaoFactoryJena wadf) {
|
public ObjectPropertyStatementDaoSDB(
|
||||||
|
DatasetWrapperFactory datasetWrapperFactory,
|
||||||
|
WebappDaoFactoryJena wadf) {
|
||||||
super (wadf);
|
super (wadf);
|
||||||
this.dataset = dataset;
|
this.dwf = datasetWrapperFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,12 +58,15 @@ public class ObjectPropertyStatementDaoSDB extends
|
||||||
" OPTIONAL { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } \n" +
|
" OPTIONAL { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } \n" +
|
||||||
"} }";
|
"} }";
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
|
||||||
Model m = null;
|
Model m = null;
|
||||||
|
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||||
|
Dataset dataset = w.getDataset();
|
||||||
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
m = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
m = QueryExecutionFactory.create(QueryFactory.create(query), dataset).execConstruct();
|
||||||
} finally {
|
} finally {
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Time (ms) to query for related individuals: " + (System.currentTimeMillis() - startTime));
|
log.debug("Time (ms) to query for related individuals: " + (System.currentTimeMillis() - startTime));
|
||||||
|
@ -112,12 +117,18 @@ public class ObjectPropertyStatementDaoSDB extends
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (objPropertyStmt.getObjectURI() != null) {
|
if (objPropertyStmt.getObjectURI() != null) {
|
||||||
Individual objInd = new IndividualSDB(objPropertyStmt.getObjectURI(), dataset, getWebappDaoFactory(), m);
|
Individual objInd = new IndividualSDB(
|
||||||
|
objPropertyStmt.getObjectURI(),
|
||||||
|
this.dwf,
|
||||||
|
getWebappDaoFactory(),
|
||||||
|
m);
|
||||||
objPropertyStmt.setObject(objInd);
|
objPropertyStmt.setObject(objInd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//add object property statement to list for Individual
|
//add object property statement to list for Individual
|
||||||
if ((objPropertyStmt.getSubjectURI() != null) && (objPropertyStmt.getPropertyURI() != null) && (objPropertyStmt.getObject() != null)){
|
if ((objPropertyStmt.getSubjectURI() != null)
|
||||||
|
&& (objPropertyStmt.getPropertyURI() != null)
|
||||||
|
&& (objPropertyStmt.getObject() != null)){
|
||||||
objPropertyStmtList.add(objPropertyStmt);
|
objPropertyStmtList.add(objPropertyStmt);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
@ -26,16 +26,16 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
public class VClassDaoSDB extends VClassDaoJena {
|
public class VClassDaoSDB extends VClassDaoJena {
|
||||||
|
|
||||||
private Dataset dataset;
|
private DatasetWrapperFactory dwf;
|
||||||
private WebappDaoFactoryJena wadf;
|
|
||||||
|
|
||||||
public VClassDaoSDB(Dataset dataset, WebappDaoFactoryJena wadf) {
|
public VClassDaoSDB(DatasetWrapperFactory datasetWrapperFactory,
|
||||||
|
WebappDaoFactoryJena wadf) {
|
||||||
super(wadf);
|
super(wadf);
|
||||||
this.dataset = dataset;
|
this.dwf = datasetWrapperFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dataset getDataset() {
|
protected DatasetWrapper getDatasetWrapper() {
|
||||||
return this.dataset;
|
return dwf.getDatasetWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -63,9 +63,17 @@ public class VClassDaoSDB extends VClassDaoJena {
|
||||||
String countQueryStr = "SELECT COUNT(*) WHERE \n" +
|
String countQueryStr = "SELECT COUNT(*) WHERE \n" +
|
||||||
"{ GRAPH ?g { ?s a <" + cls.getURI() + "> } } \n";
|
"{ GRAPH ?g { ?s a <" + cls.getURI() + "> } } \n";
|
||||||
Query countQuery = QueryFactory.create(countQueryStr, Syntax.syntaxARQ);
|
Query countQuery = QueryFactory.create(countQueryStr, Syntax.syntaxARQ);
|
||||||
QueryExecution qe = QueryExecutionFactory.create(countQuery, getDataset());
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
ResultSet rs =qe.execSelect();
|
Dataset dataset = w.getDataset();
|
||||||
count = Integer.parseInt(((Literal) rs.nextSolution().get(".1")).getLexicalForm());
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
try {
|
||||||
|
QueryExecution qe = QueryExecutionFactory.create(countQuery, dataset);
|
||||||
|
ResultSet rs = qe.execSelect();
|
||||||
|
count = Integer.parseInt(((Literal) rs.nextSolution().get(".1")).getLexicalForm());
|
||||||
|
} finally {
|
||||||
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
w.close();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
aboxModel.leaveCriticalSection();
|
aboxModel.leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,28 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
|
|
||||||
public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
|
|
||||||
private Dataset dataset;
|
private DatasetWrapperFactory dwf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use when any database connection associated with the Dataset
|
||||||
|
* is managed externally
|
||||||
|
* @param ontModelSelector
|
||||||
|
* @param dataset
|
||||||
|
*/
|
||||||
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, Dataset dataset) {
|
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, Dataset dataset) {
|
||||||
super(ontModelSelector);
|
super(ontModelSelector);
|
||||||
this.dataset = dataset;
|
this.dwf = new StaticDatasetFactory(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use when any database connection associated with the Dataset
|
||||||
|
* is managed externally
|
||||||
|
* @param ontModelSelector
|
||||||
|
* @param dataset
|
||||||
|
*/
|
||||||
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, Dataset dataset, String defaultNamespace, HashSet<String> nonuserNamespaces, String[] preferredLanguages) {
|
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, Dataset dataset, String defaultNamespace, HashSet<String> nonuserNamespaces, String[] preferredLanguages) {
|
||||||
super(ontModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages);
|
super(ontModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages);
|
||||||
this.dataset = dataset;
|
this.dwf = new StaticDatasetFactory(dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +42,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
if (entityWebappDao != null)
|
if (entityWebappDao != null)
|
||||||
return entityWebappDao;
|
return entityWebappDao;
|
||||||
else
|
else
|
||||||
return entityWebappDao = new IndividualDaoSDB(dataset, this);
|
return entityWebappDao = new IndividualDaoSDB(dwf, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +50,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
if (dataPropertyStatementDao != null)
|
if (dataPropertyStatementDao != null)
|
||||||
return dataPropertyStatementDao;
|
return dataPropertyStatementDao;
|
||||||
else
|
else
|
||||||
return dataPropertyStatementDao = new DataPropertyStatementDaoSDB(dataset, this);
|
return dataPropertyStatementDao = new DataPropertyStatementDaoSDB(dwf, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,7 +58,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
if (objectPropertyStatementDao != null)
|
if (objectPropertyStatementDao != null)
|
||||||
return objectPropertyStatementDao;
|
return objectPropertyStatementDao;
|
||||||
else
|
else
|
||||||
return objectPropertyStatementDao = new ObjectPropertyStatementDaoSDB(dataset, this);
|
return objectPropertyStatementDao = new ObjectPropertyStatementDaoSDB(dwf, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +66,21 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
if (vClassDao != null)
|
if (vClassDao != null)
|
||||||
return vClassDao;
|
return vClassDao;
|
||||||
else
|
else
|
||||||
return vClassDao = new VClassDaoSDB(dataset, this);
|
return vClassDao = new VClassDaoSDB(dwf, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StaticDatasetFactory implements DatasetWrapperFactory {
|
||||||
|
|
||||||
|
private Dataset dataset;
|
||||||
|
|
||||||
|
public StaticDatasetFactory (Dataset dataset) {
|
||||||
|
this.dataset = dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetWrapper getDatasetWrapper() {
|
||||||
|
return new DatasetWrapper(dataset);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ class MultipartHttpServletRequest extends FileUploadServletRequest {
|
||||||
*/
|
*/
|
||||||
private ServletFileUpload createUploadHandler(int maxFileSize, File tempDir) {
|
private ServletFileUpload createUploadHandler(int maxFileSize, File tempDir) {
|
||||||
DiskFileItemFactory factory = new DiskFileItemFactory();
|
DiskFileItemFactory factory = new DiskFileItemFactory();
|
||||||
factory.setSizeThreshold(maxFileSize);
|
factory.setSizeThreshold(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD);
|
||||||
factory.setRepository(tempDir);
|
factory.setRepository(tempDir);
|
||||||
|
|
||||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||||
|
|
|
@ -13,13 +13,18 @@
|
||||||
<p><strong class="warning">${errMsg}</strong></p>
|
<p><strong class="warning">${errMsg}</strong></p>
|
||||||
</c:if>
|
</c:if>
|
||||||
|
|
||||||
<p>Enter Web-accessible URL of RDF document:</p>
|
<p>Enter Web-accessible URL of document containing RDF to add or remove:</p>
|
||||||
<p><input name="rdfUrl" type="text" style="width:67%;" value="<c:out value='${param.rdfUrl}'/>"/></p>
|
<p><input name="rdfUrl" type="text" style="width:67%;" value="<c:out value='${param.rdfUrl}'/>"/></p>
|
||||||
|
|
||||||
<p>Or upload a file from your computer: </p>
|
<p>Or upload a file from your computer: </p>
|
||||||
<p><input type="file" name="rdfStream"/> </p>
|
<p><input type="file" name="rdfStream"/> </p>
|
||||||
|
|
||||||
<p><input type="radio" name="mode" value="add" checked="checked"/>add RDF <input type="radio" name="mode" value="remove"/>remove RDF</p>
|
<ul style="list-style-type:none;">
|
||||||
|
<li><input type="radio" name="mode" value="directAddABox" checked="checked"/>add instance data (supports large data files)</li>
|
||||||
|
<li><input type="radio" name="mode" value="add"/>add mixed RDF (instances and/or ontology)</li>
|
||||||
|
<li><input type="radio" name="mode" value="remove"/>remove mixed RDF (instances and/or ontology)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<select name="language">
|
<select name="language">
|
||||||
<option value="RDF/XML">RDF/XML</option>
|
<option value="RDF/XML">RDF/XML</option>
|
||||||
<option value="N3">N3</option>
|
<option value="N3">N3</option>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue