improvements to superclass methods in VClassDaoJena to support VIVO-60
This commit is contained in:
parent
aa9be9469c
commit
dae9c0c12f
9 changed files with 40 additions and 25 deletions
|
@ -12,6 +12,7 @@ public class WebappDaoFactoryConfig {
|
|||
private List<String> preferredLanguages;
|
||||
private String defaultNamespace;
|
||||
private Set<String> nonUserNamespaces;
|
||||
private boolean isUnderlyingStoreReasoned = false;
|
||||
|
||||
public WebappDaoFactoryConfig() {
|
||||
preferredLanguages = Arrays.asList("en-US", "en", "EN");
|
||||
|
@ -44,4 +45,12 @@ public class WebappDaoFactoryConfig {
|
|||
this.nonUserNamespaces = nonUserNamespaces;
|
||||
}
|
||||
|
||||
public void setUnderlyingStoreReasoned(boolean isReasoned) {
|
||||
this.isUnderlyingStoreReasoned = isReasoned;
|
||||
}
|
||||
|
||||
public boolean isUnderlyingStoreReasoned() {
|
||||
return this.isUnderlyingStoreReasoned;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -310,7 +310,6 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
ResultSet rs = qe.execSelect();
|
||||
if (rs.hasNext()) {
|
||||
QuerySolution qsoln = rs.nextSolution();
|
||||
log.debug(qsoln);
|
||||
Resource groupRes = qsoln.getResource("group");
|
||||
if (groupRes != null) {
|
||||
op.setGroupURI(groupRes.getURI());
|
||||
|
|
|
@ -66,9 +66,11 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
|||
public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||
|
||||
protected static final Log log = LogFactory.getLog(VClassDaoJena.class);
|
||||
private boolean isUnderlyingStoreReasoned = false;
|
||||
|
||||
public VClassDaoJena(WebappDaoFactoryJena wadf) {
|
||||
public VClassDaoJena(WebappDaoFactoryJena wadf, boolean isUnderlyingStoreReasoned) {
|
||||
super(wadf);
|
||||
this.isUnderlyingStoreReasoned = isUnderlyingStoreReasoned;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +78,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
return getOntModelSelector().getTBoxModel();
|
||||
}
|
||||
|
||||
protected boolean isUnderlyingStoreReasoned() {
|
||||
return this.isUnderlyingStoreReasoned;
|
||||
}
|
||||
|
||||
/* ************************************************** */
|
||||
|
||||
public String getLabelForClass(OntClass cls,boolean withPrefix,boolean forPickList) {
|
||||
|
@ -412,14 +418,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
|
||||
List<String> superclassURIs = null;
|
||||
|
||||
//String infersTypes = getWebappDaoFactory().getProperties().get("infersTypes");
|
||||
//if ("true".equalsIgnoreCase(infersTypes)) {
|
||||
|
||||
PelletListener pl = getWebappDaoFactory().getPelletListener();
|
||||
if (pl != null && pl.isConsistent() && !pl.isInErrorState() && !pl.isReasoning()) {
|
||||
if (isUnderlyingStoreReasoned()) {
|
||||
superclassURIs = new ArrayList<String>();
|
||||
OntClass cls = getOntClass(getOntModel(),classURI);
|
||||
StmtIterator superClassIt = getOntModel().listStatements(cls,RDFS.subClassOf,(RDFNode)null);
|
||||
Resource cls = ResourceFactory.createResource(classURI);
|
||||
StmtIterator superClassIt = getOntModel().listStatements(
|
||||
cls, RDFS.subClassOf, (RDFNode)null);
|
||||
while (superClassIt.hasNext()) {
|
||||
Statement stmt = superClassIt.nextStatement();
|
||||
if (stmt.getObject().canAs(OntResource.class)) {
|
||||
|
@ -766,12 +769,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
|||
}
|
||||
if (superVclass != null) {
|
||||
vClasses.add(superVclass);
|
||||
String isInferencing = getWebappDaoFactory().getProperties().get("infersTypes");
|
||||
// if this model infers types based on the taxonomy, adding the subclasses will only
|
||||
// waste time for no benefit
|
||||
PelletListener pl = getWebappDaoFactory().getPelletListener();
|
||||
if (pl == null || !pl.isConsistent() || pl.isInErrorState() || pl.isReasoning()
|
||||
|| isInferencing == null || "false".equalsIgnoreCase(isInferencing)) {
|
||||
if (!isUnderlyingStoreReasoned()) {
|
||||
Iterator classURIs = getAllSubClassURIs(getClassURIStr(superclass)).iterator();
|
||||
while (classURIs.hasNext()) {
|
||||
String classURI = (String) classURIs.next();
|
||||
|
|
|
@ -35,8 +35,8 @@ public class VClassDaoSDB extends VClassDaoJena {
|
|||
|
||||
public VClassDaoSDB(DatasetWrapperFactory datasetWrapperFactory,
|
||||
SDBDatasetMode datasetMode,
|
||||
WebappDaoFactoryJena wadf) {
|
||||
super(wadf);
|
||||
WebappDaoFactoryJena wadf, boolean isUnderlyingStoreReasoned) {
|
||||
super(wadf, isUnderlyingStoreReasoned);
|
||||
this.dwf = datasetWrapperFactory;
|
||||
this.datasetMode = datasetMode;
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
|||
protected VClassDao vClassDao = null;
|
||||
public VClassDao getVClassDao() {
|
||||
if( vClassDao == null )
|
||||
vClassDao = new VClassDaoJena(this);
|
||||
vClassDao = new VClassDaoJena(this, config.isUnderlyingStoreReasoned());
|
||||
return vClassDao;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
|||
if (vClassDao != null)
|
||||
return vClassDao;
|
||||
else
|
||||
return vClassDao = new VClassDaoSDB(dwf, datasetMode, this);
|
||||
return vClassDao = new VClassDaoSDB(dwf, datasetMode, this, config.isUnderlyingStoreReasoned());
|
||||
}
|
||||
|
||||
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class RequestModelsPrep implements Filter {
|
|||
Dataset dataset = new RDFServiceDataset(rdfService);
|
||||
vreq.setDataset(dataset);
|
||||
|
||||
WebappDaoFactoryConfig config = createWadfConfig(langs);
|
||||
WebappDaoFactoryConfig config = createWadfConfig(langs, req);
|
||||
|
||||
WebappDaoFactory assertions = new WebappDaoFactorySDB(rdfService,
|
||||
ModelAccess.on(ctx).getBaseOntModelSelector(), config,
|
||||
|
@ -175,10 +175,11 @@ public class RequestModelsPrep implements Filter {
|
|||
ModelAccess.on(vreq).setWebappDaoFactory(filteredWadf);
|
||||
}
|
||||
|
||||
private WebappDaoFactoryConfig createWadfConfig(List<String> langs) {
|
||||
private WebappDaoFactoryConfig createWadfConfig(List<String> langs, HttpServletRequest req) {
|
||||
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
||||
config.setDefaultNamespace(defaultNamespace);
|
||||
config.setPreferredLanguages(langs);
|
||||
config.setUnderlyingStoreReasoned(isStoreReasoned(req));
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -213,6 +214,12 @@ public class RequestModelsPrep implements Filter {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isStoreReasoned(ServletRequest req) {
|
||||
String isStoreReasoned = ConfigurationProperties.getBean(req).getProperty(
|
||||
"VitroConnection.DataSource.isStoreReasoned", "true");
|
||||
return ("true".equals(isStoreReasoned));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// Nothing to destroy
|
||||
|
|
Loading…
Add table
Reference in a new issue