NIHVIVO-3312 cleanup of WebappDaoFactory

This commit is contained in:
brianjlowe 2011-11-15 15:40:54 +00:00
parent f093795db1
commit 589f1242c4
8 changed files with 212 additions and 315 deletions

View file

@ -28,7 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroModelProperties; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class VclassEditController extends BaseEditController { public class VclassEditController extends BaseEditController {

View file

@ -33,7 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroModelProperties; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;

View file

@ -5,44 +5,22 @@ package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
public class VitroModelProperties { public class WebappDaoFactoryConfig {
public static final int RDF_ABOX_ONLY = 50;
public static final int RDFS = 100;
public static final int OWL_FULL = 200;
public static final int OWL_DL = 202;
public static final int OWL_LITE = 204;
private int languageProfile;
private String[] preferredLanguages; private String[] preferredLanguages;
private String defaultNamespace; private String defaultNamespace;
private Set<String> nonUserNamespaces; private Set<String> nonUserNamespaces;
public static boolean isOWL(int languageProfile) { public WebappDaoFactoryConfig() {
return ((OWL_FULL <= languageProfile && OWL_LITE >= languageProfile)); preferredLanguages = new String[3];
} preferredLanguages[0] = "en-US";
preferredLanguages[1] = "en";
public static boolean isRDFS(int languageProfile) { preferredLanguages[2] = "EN";
return (languageProfile==100);
}
public VitroModelProperties() {
languageProfile = 200;
preferredLanguages = new String[1];
preferredLanguages[0] = null;
defaultNamespace = "http://vitro.mannlib.cornell.edu/ns/default#"; defaultNamespace = "http://vitro.mannlib.cornell.edu/ns/default#";
nonUserNamespaces = new HashSet<String>(); nonUserNamespaces = new HashSet<String>();
nonUserNamespaces.add(VitroVocabulary.vitroURI); nonUserNamespaces.add(VitroVocabulary.vitroURI);
} }
public int getLanguageProfile() {
return this.languageProfile;
}
public void setLanguageProfile(int languageProfile) {
this.languageProfile = languageProfile;
}
public String[] getPreferredLanguages() { public String[] getPreferredLanguages() {
return this.preferredLanguages; return this.preferredLanguages;
} }

View file

@ -25,11 +25,8 @@ import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.OWL;
import com.hp.hpl.jena.vocabulary.RDF; import com.hp.hpl.jena.vocabulary.RDF;
@ -38,6 +35,7 @@ import com.hp.hpl.jena.vocabulary.RDFS;
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;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
public class JenaModelUtils { public class JenaModelUtils {
@ -67,7 +65,10 @@ public class JenaModelUtils {
SimpleOntModelSelector oms = new SimpleOntModelSelector(); SimpleOntModelSelector oms = new SimpleOntModelSelector();
oms.setTBoxModel(ontModel); oms.setTBoxModel(ontModel);
oms.setApplicationMetadataModel(modelForClassgroups); oms.setApplicationMetadataModel(modelForClassgroups);
WebappDaoFactory myWebappDaoFactory = new WebappDaoFactoryJena(new SimpleOntModelSelector(ontModel),wadf.getDefaultNamespace(),null,null,null); WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
config.setDefaultNamespace(wadf.getDefaultNamespace());
WebappDaoFactory myWebappDaoFactory = new WebappDaoFactoryJena(
new SimpleOntModelSelector(ontModel), config, null);
OntModel tempModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); OntModel tempModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
Resource classGroupClass = ResourceFactory.createResource(VitroVocabulary.CLASSGROUP); Resource classGroupClass = ResourceFactory.createResource(VitroVocabulary.CLASSGROUP);
Property inClassGroupProperty = ResourceFactory.createProperty(VitroVocabulary.IN_CLASSGROUP); Property inClassGroupProperty = ResourceFactory.createProperty(VitroVocabulary.IN_CLASSGROUP);

View file

@ -54,6 +54,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
@ -72,17 +73,12 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
protected OntModelSelector ontModelSelector; protected OntModelSelector ontModelSelector;
protected String defaultNamespace; protected WebappDaoFactoryConfig config;
protected HashSet<String> nonuserNamespaces;
protected String[] preferredLanguages;
protected PelletListener pelletListener; protected PelletListener pelletListener;
protected String userURI; protected String userURI;
protected boolean INCLUDE_TOP_CONCEPT = false;
protected boolean INCLUDE_BOTTOM_CONCEPT = false;
private Map<String,String> properties = new HashMap<String,String>(); private Map<String,String> properties = new HashMap<String,String>();
protected DatasetWrapperFactory dwf; protected DatasetWrapperFactory dwf;
@ -91,9 +87,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
public WebappDaoFactoryJena(WebappDaoFactoryJena base, String userURI) { public WebappDaoFactoryJena(WebappDaoFactoryJena base, String userURI) {
this.ontModelSelector = base.ontModelSelector; this.ontModelSelector = base.ontModelSelector;
this.defaultNamespace = base.defaultNamespace; this.config = base.config;
this.nonuserNamespaces = base.nonuserNamespaces;
this.preferredLanguages = base.preferredLanguages;
this.userURI = userURI; this.userURI = userURI;
this.dwf = base.dwf; this.dwf = base.dwf;
} }
@ -101,50 +95,12 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
public WebappDaoFactoryJena(OntModelSelector ontModelSelector, public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
OntModelSelector baseOntModelSelector, OntModelSelector baseOntModelSelector,
OntModelSelector inferenceOntModelSelector, OntModelSelector inferenceOntModelSelector,
String defaultNamespace, WebappDaoFactoryConfig config,
HashSet<String> nonuserNamespaces, String userURI) {
String[] preferredLanguages,
String userURI){
this.ontModelSelector = ontModelSelector; this.ontModelSelector = ontModelSelector;
this.config = config;
if (defaultNamespace != null) {
this.defaultNamespace = defaultNamespace;
} else {
initDefaultNamespace();
}
if (nonuserNamespaces != null) {
this.nonuserNamespaces = nonuserNamespaces;
} else {
initNonuserNamespaces();
}
if (preferredLanguages != null) {
this.preferredLanguages = preferredLanguages;
} else {
initPreferredLanguages();
}
this.userURI = userURI; this.userURI = userURI;
Model languageUniversalsModel = ModelFactory.createDefaultModel();
if (INCLUDE_TOP_CONCEPT) {
Resource top = getTopConcept();
if (top != null) {
languageUniversalsModel.add(top, RDF.type,
this.ontModelSelector.getTBoxModel().getProfile()
.CLASS());
}
}
if (INCLUDE_BOTTOM_CONCEPT) {
Resource bottom = getBottomConcept();
if (bottom != null) {
languageUniversalsModel.add(bottom, RDF.type,
this.ontModelSelector.getTBoxModel().getProfile()
.CLASS());
}
}
if (languageUniversalsModel.size()>0) {
this.ontModelSelector.getTBoxModel().addSubModel(
languageUniversalsModel);
}
Model assertions = (baseOntModelSelector != null) Model assertions = (baseOntModelSelector != null)
? baseOntModelSelector.getFullModel() ? baseOntModelSelector.getFullModel()
@ -158,6 +114,45 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
} }
public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
WebappDaoFactoryConfig config,
String userURI) {
this(ontModelSelector, null, null, config, userURI);
}
public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
WebappDaoFactoryConfig config) {
this(ontModelSelector, config, null);
}
public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
OntModelSelector baseOntModelSelector,
OntModelSelector inferenceOntModelSelector,
WebappDaoFactoryConfig config) {
this(ontModelSelector,
baseOntModelSelector,
inferenceOntModelSelector,
config,
null);
}
public WebappDaoFactoryJena(OntModelSelector ontModelSelector) {
this(ontModelSelector, new WebappDaoFactoryConfig(), null);
}
public WebappDaoFactoryJena(OntModel ontModel) {
this(new SimpleOntModelSelector(
ontModel), new WebappDaoFactoryConfig(), null);
}
public OntModelSelector getOntModelSelector() {
return this.ontModelSelector;
}
public OntModel getOntModel() {
return this.ontModelSelector.getFullModel();
}
public static Dataset makeInMemoryDataset(Model assertions, public static Dataset makeInMemoryDataset(Model assertions,
Model inferences) { Model inferences) {
DataSource dataset = DatasetFactory.create(); DataSource dataset = DatasetFactory.create();
@ -176,128 +171,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
return dataset; return dataset;
} }
public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
String defaultNamespace,
HashSet<String> nonuserNamespaces,
String[] preferredLanguages,
String userURI){
this(ontModelSelector,
null,
null,
defaultNamespace,
nonuserNamespaces,
preferredLanguages,
userURI);
}
public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
String defaultNamespace,
HashSet<String> nonuserNamespaces,
String[] preferredLanguages) {
this(ontModelSelector,
defaultNamespace,
nonuserNamespaces,
preferredLanguages,
null);
}
public WebappDaoFactoryJena(OntModelSelector ontModelSelector,
OntModelSelector baseOntModelSelector,
OntModelSelector inferenceOntModelSelector,
String defaultNamespace,
HashSet<String> nonuserNamespaces,
String[] preferredLanguages){
this(ontModelSelector,
baseOntModelSelector,
inferenceOntModelSelector,
defaultNamespace,
nonuserNamespaces,
preferredLanguages,
null);
}
public WebappDaoFactoryJena(OntModelSelector ontModelSelector) {
this(ontModelSelector, null, null, null, null, null);
}
public WebappDaoFactoryJena(OntModel ontModel,
String defaultNamespace,
HashSet<String> nonuserNamespaces,
String[] preferredLanguages,
String userURI) {
this(new SimpleOntModelSelector(ontModel),
defaultNamespace,
nonuserNamespaces,
preferredLanguages,
userURI);
}
public WebappDaoFactoryJena(OntModel ontModel,
String defaultNamespace,
HashSet<String> nonuserNamespaces,
String[] preferredLanguages) {
this(new SimpleOntModelSelector(ontModel),
defaultNamespace,
nonuserNamespaces,
preferredLanguages,
null);
}
public WebappDaoFactoryJena(OntModel ontModel) {
this(new SimpleOntModelSelector(
ontModel), null, null, null, null, null);
}
public OntModelSelector getOntModelSelector() {
return this.ontModelSelector;
}
public OntModel getOntModel() {
return this.ontModelSelector.getFullModel();
}
/**
* Return the current language profile's Top concept as a Jena resource,
* or null if not applicable. The special case is RDFS, where we use
* rdfs:Resource as the analog of Top, rather than returning null.
* @return
*/
public Resource getTopConcept() {
Resource top = null;
if (this.ontModelSelector.getTBoxModel().getProfile().NAMESPACE()
.equals(RDFS.getURI())) {
top = RDFS.Resource;
} else {
top = this.ontModelSelector.getTBoxModel().getProfile().THING();
}
return top;
}
/**
* Return the current language profile's Bottom concept as a Jena resource,
* or null if not applicable.
* @return
*/
public Resource getBottomConcept() {
return this.ontModelSelector.getTBoxModel().getProfile().THING();
}
private void initDefaultNamespace() {
defaultNamespace = "http://vivo.library.cornell.edu/ns/0.1#";
}
private void initNonuserNamespaces() {
nonuserNamespaces = new HashSet<String>();
nonuserNamespaces.add(VitroVocabulary.vitroURI);
}
private void initPreferredLanguages() {
preferredLanguages = new String[3];
preferredLanguages[0] = "en-US";
preferredLanguages[1] = "en";
preferredLanguages[2] = "EN";
}
/* ******************************************** */ /* ******************************************** */
public Map<String,String> getProperties() { public Map<String,String> getProperties() {
@ -366,15 +239,15 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
/* **************** accessors ***************** */ /* **************** accessors ***************** */
public String getDefaultNamespace() { public String getDefaultNamespace() {
return defaultNamespace; return config.getDefaultNamespace();
} }
public String[] getPreferredLanguages() { public String[] getPreferredLanguages() {
return this.preferredLanguages; return config.getPreferredLanguages();
} }
public Set<String> getNonuserNamespaces() { public Set<String> getNonuserNamespaces() {
return nonuserNamespaces; return config.getNonUserNamespaces();
} }
/** /**
@ -595,9 +468,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
//Not sure what this is but will set to equivalence here //Not sure what this is but will set to equivalence here
this.ontModelSelector = base.ontModelSelector; this.ontModelSelector = base.ontModelSelector;
} }
this.defaultNamespace = base.defaultNamespace; this.config = base.config;
this.nonuserNamespaces = base.nonuserNamespaces;
this.preferredLanguages = base.preferredLanguages;
this.userURI = base.userURI; this.userURI = base.userURI;
this.dwf = base.dwf; this.dwf = base.dwf;
} }

View file

@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
public class WebappDaoFactorySDB extends WebappDaoFactoryJena { public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
@ -30,7 +31,8 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
* For use when any database connection associated with the Dataset * For use when any database connection associated with the Dataset
* is managed externally * is managed externally
*/ */
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, Dataset dataset) { public WebappDaoFactorySDB(OntModelSelector ontModelSelector,
Dataset dataset) {
super(ontModelSelector); super(ontModelSelector);
this.dwf = new StaticDatasetFactory(dataset); this.dwf = new StaticDatasetFactory(dataset);
} }
@ -41,10 +43,8 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
*/ */
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, public WebappDaoFactorySDB(OntModelSelector ontModelSelector,
Dataset dataset, Dataset dataset,
String defaultNamespace, WebappDaoFactoryConfig config) {
HashSet<String> nonuserNamespaces, super(ontModelSelector, config);
String[] preferredLanguages) {
super(ontModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages);
this.dwf = new StaticDatasetFactory(dataset); this.dwf = new StaticDatasetFactory(dataset);
} }
@ -55,10 +55,8 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, public WebappDaoFactorySDB(OntModelSelector ontModelSelector,
BasicDataSource bds, BasicDataSource bds,
StoreDesc storeDesc, StoreDesc storeDesc,
String defaultNamespace, WebappDaoFactoryConfig config) {
HashSet<String> nonuserNamespaces, super(ontModelSelector, config);
String[] preferredLanguages) {
super(ontModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages);
this.dwf = new ReconnectingDatasetFactory(bds, storeDesc); this.dwf = new ReconnectingDatasetFactory(bds, storeDesc);
} }
@ -69,11 +67,9 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
public WebappDaoFactorySDB(OntModelSelector ontModelSelector, public WebappDaoFactorySDB(OntModelSelector ontModelSelector,
BasicDataSource bds, BasicDataSource bds,
StoreDesc storeDesc, StoreDesc storeDesc,
String defaultNamespace, WebappDaoFactoryConfig config,
HashSet<String> nonuserNamespaces,
String[] preferredLanguages,
SDBDatasetMode datasetMode) { SDBDatasetMode datasetMode) {
super(ontModelSelector, defaultNamespace, nonuserNamespaces, preferredLanguages); super(ontModelSelector, config);
this.dwf = new ReconnectingDatasetFactory(bds, storeDesc); this.dwf = new ReconnectingDatasetFactory(bds, storeDesc);
this.datasetMode = datasetMode; this.datasetMode = datasetMode;
} }
@ -82,9 +78,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
public WebappDaoFactorySDB(WebappDaoFactorySDB base, String userURI) { public WebappDaoFactorySDB(WebappDaoFactorySDB base, String userURI) {
super(base.ontModelSelector); super(base.ontModelSelector);
this.ontModelSelector = base.ontModelSelector; this.ontModelSelector = base.ontModelSelector;
this.defaultNamespace = base.defaultNamespace; this.config = base.config;
this.nonuserNamespaces = base.nonuserNamespaces;
this.preferredLanguages = base.preferredLanguages;
this.userURI = userURI; this.userURI = userURI;
this.dwf = base.dwf; this.dwf = base.dwf;
} }
@ -125,7 +119,6 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
} }
public WebappDaoFactory getUserAwareDaoFactory(String userURI) { public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
// TODO: put the user-aware factories in a hashmap so we don't keep re-creating them
return new WebappDaoFactorySDB(this, userURI); return new WebappDaoFactorySDB(this, userURI);
} }
@ -174,7 +167,8 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
private BasicDataSource _bds; private BasicDataSource _bds;
private StoreDesc _storeDesc; private StoreDesc _storeDesc;
public ReconnectingDatasetFactory(BasicDataSource bds, StoreDesc storeDesc) { public ReconnectingDatasetFactory(BasicDataSource bds,
StoreDesc storeDesc) {
_bds = bds; _bds = bds;
_storeDesc = storeDesc; _storeDesc = storeDesc;
} }
@ -187,7 +181,8 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
Dataset dataset = SDBFactory.connectDataset(store); Dataset dataset = SDBFactory.connectDataset(store);
return new DatasetWrapper(dataset, conn); return new DatasetWrapper(dataset, conn);
} catch (SQLException sqe) { } catch (SQLException sqe) {
throw new RuntimeException("Unable to connect to database", sqe); throw new RuntimeException(
"Unable to connect to database", sqe);
} }
} }

View file

@ -31,6 +31,7 @@ import com.hp.hpl.jena.sdb.sql.SDBConnection;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector; import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
@ -103,8 +104,9 @@ public class WebappDaoFactorySDBPrep implements Filter {
store = SDBFactory.connectStore(conn, storeDesc); store = SDBFactory.connectStore(conn, storeDesc);
dataset = SDBFactory.connectDataset(store); dataset = SDBFactory.connectDataset(store);
VitroRequest vreq = new VitroRequest((HttpServletRequest) request); VitroRequest vreq = new VitroRequest((HttpServletRequest) request);
wadf = WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
new WebappDaoFactorySDB(oms, dataset, defaultNamespace, null, null); config.setDefaultNamespace(defaultNamespace);
wadf = new WebappDaoFactorySDB(oms, dataset, config);
vreq.setWebappDaoFactory(wadf); vreq.setWebappDaoFactory(wadf);
vreq.setFullWebappDaoFactory(wadf); vreq.setFullWebappDaoFactory(wadf);
vreq.setDataset(dataset); vreq.setDataset(dataset);

View file

@ -43,6 +43,7 @@ import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaModelUtils;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
@ -54,7 +55,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
import edu.cornell.mannlib.vitro.webapp.utils.jena.InitialJenaModelUtils; import edu.cornell.mannlib.vitro.webapp.utils.jena.InitialJenaModelUtils;
public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements javax.servlet.ServletContextListener { public class JenaDataSourceSetup extends JenaDataSourceSetupBase
implements javax.servlet.ServletContextListener {
private static final Log log = LogFactory.getLog(JenaDataSourceSetup.class); private static final Log log = LogFactory.getLog(JenaDataSourceSetup.class);
@ -120,38 +122,57 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
} }
} }
// The code below, which sets up the OntModelSelectors, controls whether each // The code below, which sets up the OntModelSelectors, controls whether
// model is maintained in memory, in the DB, or both while the application // each model is maintained in memory, in the DB, or both while the
// is running. // application is running.
// Populate the three OntModelSelectors (BaseOntModel=assertions, InferenceOntModel=inferences // Populate the three OntModelSelectors (BaseOntModel = assertions,
// and JenaOntModel=union of assertions and inferences) with the post-SDB-conversion models. // InferenceOntModel = inferences and JenaOntModel = union of assertions
// and inferences) with the post-SDB-conversion models.
// ABox assertions // ABox assertions
Model aboxAssertions = makeDBModel(bds, JenaDataSourceSetupBase.JENA_DB_MODEL, DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx); Model aboxAssertions = makeDBModel(
Model listenableAboxAssertions = ModelFactory.createUnion(aboxAssertions, ModelFactory.createDefaultModel()); bds, JenaDataSourceSetupBase.JENA_DB_MODEL, DB_ONT_MODEL_SPEC,
baseOms.setABoxModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, listenableAboxAssertions)); TripleStoreType.SDB, ctx);
Model listenableAboxAssertions = ModelFactory.createUnion(
aboxAssertions, ModelFactory.createDefaultModel());
baseOms.setABoxModel(
ModelFactory.createOntologyModel(
OntModelSpec.OWL_MEM, listenableAboxAssertions));
// ABox inferences // ABox inferences
Model aboxInferences = makeDBModel(bds, JenaDataSourceSetupBase.JENA_INF_MODEL, DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx); Model aboxInferences = makeDBModel(
Model listenableAboxInferences = ModelFactory.createUnion(aboxInferences, ModelFactory.createDefaultModel()); bds, JenaDataSourceSetupBase.JENA_INF_MODEL, DB_ONT_MODEL_SPEC,
inferenceOms.setABoxModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, listenableAboxInferences)); TripleStoreType.SDB, ctx);
Model listenableAboxInferences = ModelFactory.createUnion(
aboxInferences, ModelFactory.createDefaultModel());
inferenceOms.setABoxModel(ModelFactory.createOntologyModel(
OntModelSpec.OWL_MEM, listenableAboxInferences));
// Since the TBox models are in memory, they do not have timeout issues
// like the like the ABox models do (and so don't need the extra step
// to make them listenable.)
// Since the TBox models are in memory, they do not have time out issues like the
// ABox models do (and so don't need the extra step to make them listenable).
// TBox assertions // TBox assertions
try { try {
Model tboxAssertionsDB = makeDBModel(bds, JENA_TBOX_ASSERTIONS_MODEL, DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx); Model tboxAssertionsDB = makeDBModel(
OntModel tboxAssertions = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC); bds, JENA_TBOX_ASSERTIONS_MODEL, DB_ONT_MODEL_SPEC,
TripleStoreType.SDB, ctx);
OntModel tboxAssertions = ModelFactory.createOntologyModel(
MEM_ONT_MODEL_SPEC);
if (tboxAssertionsDB != null) { if (tboxAssertionsDB != null) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
System.out.println("Copying cached tbox assertions into memory"); System.out.println(
"Copying cached tbox assertions into memory");
tboxAssertions.add(tboxAssertionsDB); tboxAssertions.add(tboxAssertionsDB);
System.out.println((System.currentTimeMillis()-startTime)/1000+" seconds to load tbox assertions"); System.out.println((System.currentTimeMillis() - startTime)
/ 1000 + " seconds to load tbox assertions");
} }
tboxAssertions.getBaseModel().register(new ModelSynchronizer(tboxAssertionsDB)); tboxAssertions.getBaseModel().register(new ModelSynchronizer(
tboxAssertionsDB));
baseOms.setTBoxModel(tboxAssertions); baseOms.setTBoxModel(tboxAssertions);
} catch (Throwable e) { } catch (Throwable e) {
log.error("Unable to load tbox assertion cache from DB", e); log.error("Unable to load tbox assertion cache from DB", e);
@ -159,56 +180,80 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
// TBox inferences // TBox inferences
try { try {
Model tboxInferencesDB = makeDBModel(bds, JENA_TBOX_INF_MODEL, DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx); Model tboxInferencesDB = makeDBModel(
OntModel tboxInferences = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC); bds, JENA_TBOX_INF_MODEL, DB_ONT_MODEL_SPEC,
TripleStoreType.SDB, ctx);
OntModel tboxInferences = ModelFactory.createOntologyModel(
MEM_ONT_MODEL_SPEC);
if (tboxInferencesDB != null) { if (tboxInferencesDB != null) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
System.out.println("Copying cached tbox inferences into memory"); System.out.println(
"Copying cached tbox inferences into memory");
tboxInferences.add(tboxInferencesDB); tboxInferences.add(tboxInferencesDB);
System.out.println((System.currentTimeMillis()-startTime)/1000+" seconds to load tbox inferences"); System.out.println((System.currentTimeMillis() - startTime)
/ 1000 + " seconds to load tbox inferences");
} }
tboxInferences.getBaseModel().register(new ModelSynchronizer(tboxInferencesDB)); tboxInferences.getBaseModel().register(new ModelSynchronizer(
tboxInferencesDB));
inferenceOms.setTBoxModel(tboxInferences); inferenceOms.setTBoxModel(tboxInferences);
} catch (Throwable e) { } catch (Throwable e) {
log.error("Unable to load tbox inference cache from DB", e); log.error("Unable to load tbox inference cache from DB", e);
} }
// union ABox // union ABox
OntModel unionABoxModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC,ModelFactory.createUnion(baseOms.getABoxModel(), inferenceOms.getABoxModel())); OntModel unionABoxModel = ModelFactory.createOntologyModel(
MEM_ONT_MODEL_SPEC,ModelFactory.createUnion(
baseOms.getABoxModel(), inferenceOms.getABoxModel()));
unionOms.setABoxModel(unionABoxModel); unionOms.setABoxModel(unionABoxModel);
// union TBox // union TBox
OntModel unionTBoxModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC,ModelFactory.createUnion(baseOms.getTBoxModel(), inferenceOms.getTBoxModel())); OntModel unionTBoxModel = ModelFactory.createOntologyModel(
MEM_ONT_MODEL_SPEC,ModelFactory.createUnion(
baseOms.getTBoxModel(), inferenceOms.getTBoxModel()));
unionOms.setTBoxModel(unionTBoxModel); unionOms.setTBoxModel(unionTBoxModel);
// Application metadata model is cached in memory. // Application metadata model is cached in memory.
try { try {
Model applicationMetadataModelDB = makeDBModel(bds, JENA_APPLICATION_METADATA_MODEL, DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx); Model applicationMetadataModelDB = makeDBModel(
OntModel applicationMetadataModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC); bds, JENA_APPLICATION_METADATA_MODEL, DB_ONT_MODEL_SPEC,
TripleStoreType.SDB, ctx);
OntModel applicationMetadataModel =
ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC);
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
System.out.println("Copying cached application metadata model into memory"); System.out.println(
"Copying cached application metadata model into memory");
applicationMetadataModel.add(applicationMetadataModelDB); applicationMetadataModel.add(applicationMetadataModelDB);
System.out.println((System.currentTimeMillis()-startTime)/1000+" seconds to load application metadata model assertions of size " + applicationMetadataModel.size()); System.out.println((System.currentTimeMillis() - startTime)
applicationMetadataModel.getBaseModel().register(new ModelSynchronizer(applicationMetadataModelDB)); / 1000 + " seconds to load application metadata model " +
"assertions of size " + applicationMetadataModel.size());
applicationMetadataModel.getBaseModel().register(
new ModelSynchronizer(applicationMetadataModelDB));
if (isFirstStartup()) { if (isFirstStartup()) {
applicationMetadataModel.add(InitialJenaModelUtils.loadInitialModel(ctx, getDefaultNamespace(ctx))); applicationMetadataModel.add(
InitialJenaModelUtils.loadInitialModel(
ctx, getDefaultNamespace(ctx)));
} else if (applicationMetadataModelDB.size() == 0) { } else if (applicationMetadataModelDB.size() == 0) {
repairAppMetadataModel(applicationMetadataModel, aboxAssertions, aboxInferences); repairAppMetadataModel(
applicationMetadataModel, aboxAssertions,
aboxInferences);
} }
baseOms.setApplicationMetadataModel(applicationMetadataModel); baseOms.setApplicationMetadataModel(applicationMetadataModel);
inferenceOms.setApplicationMetadataModel(baseOms.getApplicationMetadataModel()); inferenceOms.setApplicationMetadataModel(
unionOms.setApplicationMetadataModel(baseOms.getApplicationMetadataModel()); baseOms.getApplicationMetadataModel());
unionOms.setApplicationMetadataModel(
baseOms.getApplicationMetadataModel());
} catch (Throwable e) { } catch (Throwable e) {
log.error("Unable to load application metadata model cache from DB", e); log.error("Unable to load application metadata model cache from DB"
, e);
} }
checkForNamespaceMismatch( baseOms.getApplicationMetadataModel(), ctx ); checkForNamespaceMismatch( baseOms.getApplicationMetadataModel(), ctx );
@ -220,31 +265,28 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
log.info("Setting up union models and DAO factories"); log.info("Setting up union models and DAO factories");
// create TBox + ABox union models and set up webapp DAO factories // create TBox + ABox union models and set up webapp DAO factories
OntModel baseUnion = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, OntModel baseUnion = ModelFactory.createOntologyModel(
ModelFactory.createUnion(baseOms.getABoxModel(), baseOms.getTBoxModel())); OntModelSpec.OWL_MEM,
ModelFactory.createUnion(baseOms.getABoxModel(),
baseOms.getTBoxModel()));
baseOms.setFullModel(baseUnion); baseOms.setFullModel(baseUnion);
ModelContext.setBaseOntModel(baseOms.getFullModel(), ctx); ModelContext.setBaseOntModel(baseOms.getFullModel(), ctx);
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
config.setDefaultNamespace(getDefaultNamespace(ctx));
WebappDaoFactory baseWadf = new WebappDaoFactorySDB( WebappDaoFactory baseWadf = new WebappDaoFactorySDB(
baseOms, baseOms, bds, storeDesc, config,
bds,
storeDesc,
getDefaultNamespace(ctx),
null,
null,
WebappDaoFactorySDB.SDBDatasetMode.ASSERTIONS_ONLY); WebappDaoFactorySDB.SDBDatasetMode.ASSERTIONS_ONLY);
ctx.setAttribute("assertionsWebappDaoFactory",baseWadf); ctx.setAttribute("assertionsWebappDaoFactory",baseWadf);
OntModel inferenceUnion = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, OntModel inferenceUnion = ModelFactory.createOntologyModel(
ModelFactory.createUnion(inferenceOms.getABoxModel(), inferenceOms.getTBoxModel())); OntModelSpec.OWL_MEM,
ModelFactory.createUnion(
inferenceOms.getABoxModel(),
inferenceOms.getTBoxModel()));
inferenceOms.setFullModel(inferenceUnion); inferenceOms.setFullModel(inferenceUnion);
ModelContext.setInferenceOntModel(inferenceOms.getFullModel(), ctx); ModelContext.setInferenceOntModel(inferenceOms.getFullModel(), ctx);
WebappDaoFactory infWadf = new WebappDaoFactorySDB( WebappDaoFactory infWadf = new WebappDaoFactorySDB(
inferenceOms, inferenceOms, bds, storeDesc, config,
bds,
storeDesc,
getDefaultNamespace(ctx),
null,
null,
WebappDaoFactorySDB.SDBDatasetMode.INFERENCES_ONLY); WebappDaoFactorySDB.SDBDatasetMode.INFERENCES_ONLY);
ctx.setAttribute("deductionsWebappDaoFactory", infWadf); ctx.setAttribute("deductionsWebappDaoFactory", infWadf);
@ -252,23 +294,19 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
DB_ONT_MODEL_SPEC, makeDBModel( DB_ONT_MODEL_SPEC, makeDBModel(
bds, WebappDaoFactorySDB.UNION_GRAPH, bds, WebappDaoFactorySDB.UNION_GRAPH,
DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx)); DB_ONT_MODEL_SPEC, TripleStoreType.SDB, ctx));
//OntModel masterUnion = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
// ModelFactory.createUnion(unionABoxModel, unionTBoxModel));
unionOms.setFullModel(masterUnion); unionOms.setFullModel(masterUnion);
ctx.setAttribute("jenaOntModel", masterUnion); ctx.setAttribute("jenaOntModel", masterUnion);
WebappDaoFactory wadf = new WebappDaoFactorySDB(unionOms, bds, storeDesc, getDefaultNamespace(ctx), null, null); WebappDaoFactory wadf = new WebappDaoFactorySDB(
unionOms, bds, storeDesc, config);
ctx.setAttribute("webappDaoFactory",wadf); ctx.setAttribute("webappDaoFactory",wadf);
ModelContext.setOntModelSelector(unionOms, ctx); ModelContext.setOntModelSelector(unionOms, ctx);
ModelContext.setUnionOntModelSelector(unionOms, ctx); // assertions and inferences ModelContext.setUnionOntModelSelector(unionOms, ctx);
ModelContext.setBaseOntModelSelector(baseOms, ctx); // assertions // assertions and inferences
ModelContext.setInferenceOntModelSelector(inferenceOms, ctx); // inferences ModelContext.setBaseOntModelSelector(baseOms, ctx);
// assertions
//log.info("Setting up namespace mapper"); ModelContext.setInferenceOntModelSelector(inferenceOms, ctx);
// inferences
//NamespaceMapper namespaceMapper = new NamespaceMapperJena(masterUnion, masterUnion, defaultNamespace);
//ctx.setAttribute("NamespaceMapper", namespaceMapper);
//unionOms.getFullModel().getBaseModel().register(namespaceMapper);
ctx.setAttribute("defaultNamespace", getDefaultNamespace(ctx)); ctx.setAttribute("defaultNamespace", getDefaultNamespace(ctx));
@ -352,7 +390,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
} }
/* ====================================================================== */ /* ===================================================================== */
@Override @Override
@ -360,7 +398,8 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
// Nothing to do. // Nothing to do.
} }
private OntModel ontModelFromContextAttribute(ServletContext ctx, String attribute) { private OntModel ontModelFromContextAttribute(ServletContext ctx,
String attribute) {
OntModel ontModel; OntModel ontModel;
Object attributeValue = ctx.getAttribute(attribute); Object attributeValue = ctx.getAttribute(attribute);
if (attributeValue != null && attributeValue instanceof OntModel) { if (attributeValue != null && attributeValue instanceof OntModel) {
@ -387,7 +426,8 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
} }
} }
private void loadDataFromFilesystem(OntModelSelector baseOms, ServletContext ctx) { private void loadDataFromFilesystem(OntModelSelector baseOms,
ServletContext ctx) {
Long startTime = System.currentTimeMillis(); Long startTime = System.currentTimeMillis();
log.debug("Initializing models from RDF files"); log.debug("Initializing models from RDF files");
readOntologyFilesInPathSet(USER_ABOX_PATH, ctx, baseOms.getABoxModel()); readOntologyFilesInPathSet(USER_ABOX_PATH, ctx, baseOms.getABoxModel());
@ -398,7 +438,9 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
+ " seconds to read RDF files "); + " seconds to read RDF files ");
} }
private static void getTBoxModel(Model fullModel, Model submodels, Model tboxModel) { private static void getTBoxModel(Model fullModel,
Model submodels,
Model tboxModel) {
JenaModelUtils modelUtils = new JenaModelUtils(); JenaModelUtils modelUtils = new JenaModelUtils();
@ -421,7 +463,9 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
/* /*
* Copy all statements from model 1 that are not in model 2 to model 3. * Copy all statements from model 1 that are not in model 2 to model 3.
*/ */
private static void copyDifference(Model model1, Model model2, Model model3) { private static void copyDifference(Model model1,
Model model2,
Model model3) {
StmtIterator iter = model1.listStatements(); StmtIterator iter = model1.listStatements();
@ -502,16 +546,17 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
try { try {
// This is a one-time copy of stored KB data - from a Jena RDB store // This is a one-time copy of stored KB data - from a Jena RDB store
// to a Jena SDB store. In the process, we will also separate out the // to a Jena SDB store. In the process, we will also separate out
// TBox from the Abox; these are in the same graph in pre 1.2 VIVO // the TBox from the Abox; these are in the same graph in pre-1.2
// versions and will now be stored and maintained in separate models // VIVO versions and will now be stored and maintained in separate
// Access to the Jena RDB data is through the OntModelSelectors that have // models. Access to the Jena RDB data is through the
// been set up earlier in the current session by // OntModelSelectors that have been set up earlier in the current
// JenaPersistentDataSourceSetup.java // session by JenaPersistentDataSourceSetup.java. In the code
// In the code below, note that the current getABoxModel() methods on // below, note that the current getABoxModel() methods on the
// the OntModelSelectors return a graph with both ABox and TBox data. // OntModelSelectors return a graph with both ABox and TBox data.
OntModel submodels = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC); OntModel submodels = ModelFactory.createOntologyModel(
MEM_ONT_MODEL_SPEC);
readOntologyFilesInPathSet(SUBMODELS, ctx, submodels); readOntologyFilesInPathSet(SUBMODELS, ctx, submodels);
Model tboxAssertions = SDBFactory.connectNamedModel( Model tboxAssertions = SDBFactory.connectNamedModel(
@ -540,10 +585,12 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
// Set up the application metadata model // Set up the application metadata model
Model applicationMetadataModel = SDBFactory.connectNamedModel( Model applicationMetadataModel = SDBFactory.connectNamedModel(
store, JenaDataSourceSetupBase.JENA_APPLICATION_METADATA_MODEL); store,
JenaDataSourceSetupBase.JENA_APPLICATION_METADATA_MODEL);
getAppMetadata(memModel, applicationMetadataModel); getAppMetadata(memModel, applicationMetadataModel);
log.info("During initial SDB setup, created an application metadata model of size " log.info("During initial SDB setup, created an application " +
+ applicationMetadataModel.size()); "metadata model of size " +
applicationMetadataModel.size());
// remove application metadata from ABox model // remove application metadata from ABox model
aboxAssertions.remove(applicationMetadataModel); aboxAssertions.remove(applicationMetadataModel);
@ -583,7 +630,10 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
// even if the store exists, it may be empty // even if the store exists, it may be empty
try { try {
return (SDBFactory.connectNamedModel(store, JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL)).size() > 0; return (SDBFactory.connectNamedModel(
store,
JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL))
.size() > 0;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }