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 List<String> preferredLanguages;
|
||||||
private String defaultNamespace;
|
private String defaultNamespace;
|
||||||
private Set<String> nonUserNamespaces;
|
private Set<String> nonUserNamespaces;
|
||||||
|
private boolean isUnderlyingStoreReasoned = false;
|
||||||
|
|
||||||
public WebappDaoFactoryConfig() {
|
public WebappDaoFactoryConfig() {
|
||||||
preferredLanguages = Arrays.asList("en-US", "en", "EN");
|
preferredLanguages = Arrays.asList("en-US", "en", "EN");
|
||||||
|
@ -44,4 +45,12 @@ public class WebappDaoFactoryConfig {
|
||||||
this.nonUserNamespaces = nonUserNamespaces;
|
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();
|
ResultSet rs = qe.execSelect();
|
||||||
if (rs.hasNext()) {
|
if (rs.hasNext()) {
|
||||||
QuerySolution qsoln = rs.nextSolution();
|
QuerySolution qsoln = rs.nextSolution();
|
||||||
log.debug(qsoln);
|
|
||||||
Resource groupRes = qsoln.getResource("group");
|
Resource groupRes = qsoln.getResource("group");
|
||||||
if (groupRes != null) {
|
if (groupRes != null) {
|
||||||
op.setGroupURI(groupRes.getURI());
|
op.setGroupURI(groupRes.getURI());
|
||||||
|
|
|
@ -503,7 +503,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
List<VClass> allTypes = ind.getVClasses(false); // include indirect types
|
List<VClass> allTypes = ind.getVClasses(false); // include indirect types
|
||||||
|
|
||||||
Set<String> allSuperclassURIs = new HashSet<String>();
|
Set<String> allSuperclassURIs = new HashSet<String>();
|
||||||
|
|
||||||
for (VClass type : allTypes) {
|
for (VClass type : allTypes) {
|
||||||
String classURI = type.getURI();
|
String classURI = type.getURI();
|
||||||
if (classURI != null) {
|
if (classURI != null) {
|
||||||
|
@ -718,7 +718,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
: (op.getRange() == null && foundRanges[1] != null)
|
: (op.getRange() == null && foundRanges[1] != null)
|
||||||
? foundRanges[1]
|
? foundRanges[1]
|
||||||
: op.getRange();
|
: op.getRange();
|
||||||
propInsts.add(getPropInstForPropertyAndRange(op, rangeRes, applicableProperties));
|
propInsts.add(getPropInstForPropertyAndRange(op, rangeRes, applicableProperties));
|
||||||
List<String> additionalFauxSubpropertyRangeURIs = getAdditionalFauxSubpropertyRangeURIsForPropertyURI(propertyURI);
|
List<String> additionalFauxSubpropertyRangeURIs = getAdditionalFauxSubpropertyRangeURIsForPropertyURI(propertyURI);
|
||||||
for (String rangeURI : additionalFauxSubpropertyRangeURIs) {
|
for (String rangeURI : additionalFauxSubpropertyRangeURIs) {
|
||||||
if (getWebappDaoFactory().getVClassDao().isSubClassOf(rangeURI, rangeRes.getURI())) {
|
if (getWebappDaoFactory().getVClassDao().isSubClassOf(rangeURI, rangeRes.getURI())) {
|
||||||
|
|
|
@ -66,15 +66,21 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||||
public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(VClassDaoJena.class);
|
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);
|
super(wadf);
|
||||||
|
this.isUnderlyingStoreReasoned = isUnderlyingStoreReasoned;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OntModel getOntModel() {
|
protected OntModel getOntModel() {
|
||||||
return getOntModelSelector().getTBoxModel();
|
return getOntModelSelector().getTBoxModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isUnderlyingStoreReasoned() {
|
||||||
|
return this.isUnderlyingStoreReasoned;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************** */
|
/* ************************************************** */
|
||||||
|
|
||||||
|
@ -412,14 +418,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
|
|
||||||
List<String> superclassURIs = null;
|
List<String> superclassURIs = null;
|
||||||
|
|
||||||
//String infersTypes = getWebappDaoFactory().getProperties().get("infersTypes");
|
if (isUnderlyingStoreReasoned()) {
|
||||||
//if ("true".equalsIgnoreCase(infersTypes)) {
|
|
||||||
|
|
||||||
PelletListener pl = getWebappDaoFactory().getPelletListener();
|
|
||||||
if (pl != null && pl.isConsistent() && !pl.isInErrorState() && !pl.isReasoning()) {
|
|
||||||
superclassURIs = new ArrayList<String>();
|
superclassURIs = new ArrayList<String>();
|
||||||
OntClass cls = getOntClass(getOntModel(),classURI);
|
Resource cls = ResourceFactory.createResource(classURI);
|
||||||
StmtIterator superClassIt = getOntModel().listStatements(cls,RDFS.subClassOf,(RDFNode)null);
|
StmtIterator superClassIt = getOntModel().listStatements(
|
||||||
|
cls, RDFS.subClassOf, (RDFNode)null);
|
||||||
while (superClassIt.hasNext()) {
|
while (superClassIt.hasNext()) {
|
||||||
Statement stmt = superClassIt.nextStatement();
|
Statement stmt = superClassIt.nextStatement();
|
||||||
if (stmt.getObject().canAs(OntResource.class)) {
|
if (stmt.getObject().canAs(OntResource.class)) {
|
||||||
|
@ -766,12 +769,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
}
|
}
|
||||||
if (superVclass != null) {
|
if (superVclass != null) {
|
||||||
vClasses.add(superVclass);
|
vClasses.add(superVclass);
|
||||||
String isInferencing = getWebappDaoFactory().getProperties().get("infersTypes");
|
|
||||||
// if this model infers types based on the taxonomy, adding the subclasses will only
|
// if this model infers types based on the taxonomy, adding the subclasses will only
|
||||||
// waste time for no benefit
|
// waste time for no benefit
|
||||||
PelletListener pl = getWebappDaoFactory().getPelletListener();
|
if (!isUnderlyingStoreReasoned()) {
|
||||||
if (pl == null || !pl.isConsistent() || pl.isInErrorState() || pl.isReasoning()
|
|
||||||
|| isInferencing == null || "false".equalsIgnoreCase(isInferencing)) {
|
|
||||||
Iterator classURIs = getAllSubClassURIs(getClassURIStr(superclass)).iterator();
|
Iterator classURIs = getAllSubClassURIs(getClassURIStr(superclass)).iterator();
|
||||||
while (classURIs.hasNext()) {
|
while (classURIs.hasNext()) {
|
||||||
String classURI = (String) classURIs.next();
|
String classURI = (String) classURIs.next();
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class VClassDaoSDB extends VClassDaoJena {
|
||||||
|
|
||||||
public VClassDaoSDB(DatasetWrapperFactory datasetWrapperFactory,
|
public VClassDaoSDB(DatasetWrapperFactory datasetWrapperFactory,
|
||||||
SDBDatasetMode datasetMode,
|
SDBDatasetMode datasetMode,
|
||||||
WebappDaoFactoryJena wadf) {
|
WebappDaoFactoryJena wadf, boolean isUnderlyingStoreReasoned) {
|
||||||
super(wadf);
|
super(wadf, isUnderlyingStoreReasoned);
|
||||||
this.dwf = datasetWrapperFactory;
|
this.dwf = datasetWrapperFactory;
|
||||||
this.datasetMode = datasetMode;
|
this.datasetMode = datasetMode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
||||||
protected VClassDao vClassDao = null;
|
protected VClassDao vClassDao = null;
|
||||||
public VClassDao getVClassDao() {
|
public VClassDao getVClassDao() {
|
||||||
if( vClassDao == null )
|
if( vClassDao == null )
|
||||||
vClassDao = new VClassDaoJena(this);
|
vClassDao = new VClassDaoJena(this, config.isUnderlyingStoreReasoned());
|
||||||
return vClassDao;
|
return vClassDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class WebappDaoFactorySDB extends WebappDaoFactoryJena {
|
||||||
if (vClassDao != null)
|
if (vClassDao != null)
|
||||||
return vClassDao;
|
return vClassDao;
|
||||||
else
|
else
|
||||||
return vClassDao = new VClassDaoSDB(dwf, datasetMode, this);
|
return vClassDao = new VClassDaoSDB(dwf, datasetMode, this, config.isUnderlyingStoreReasoned());
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
|
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class RequestModelsPrep implements Filter {
|
||||||
Dataset dataset = new RDFServiceDataset(rdfService);
|
Dataset dataset = new RDFServiceDataset(rdfService);
|
||||||
vreq.setDataset(dataset);
|
vreq.setDataset(dataset);
|
||||||
|
|
||||||
WebappDaoFactoryConfig config = createWadfConfig(langs);
|
WebappDaoFactoryConfig config = createWadfConfig(langs, req);
|
||||||
|
|
||||||
WebappDaoFactory assertions = new WebappDaoFactorySDB(rdfService,
|
WebappDaoFactory assertions = new WebappDaoFactorySDB(rdfService,
|
||||||
ModelAccess.on(ctx).getBaseOntModelSelector(), config,
|
ModelAccess.on(ctx).getBaseOntModelSelector(), config,
|
||||||
|
@ -175,10 +175,11 @@ public class RequestModelsPrep implements Filter {
|
||||||
ModelAccess.on(vreq).setWebappDaoFactory(filteredWadf);
|
ModelAccess.on(vreq).setWebappDaoFactory(filteredWadf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebappDaoFactoryConfig createWadfConfig(List<String> langs) {
|
private WebappDaoFactoryConfig createWadfConfig(List<String> langs, HttpServletRequest req) {
|
||||||
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
WebappDaoFactoryConfig config = new WebappDaoFactoryConfig();
|
||||||
config.setDefaultNamespace(defaultNamespace);
|
config.setDefaultNamespace(defaultNamespace);
|
||||||
config.setPreferredLanguages(langs);
|
config.setPreferredLanguages(langs);
|
||||||
|
config.setUnderlyingStoreReasoned(isStoreReasoned(req));
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +213,12 @@ public class RequestModelsPrep implements Filter {
|
||||||
ModelAccess.on(req).setOntModel(id, aware);
|
ModelAccess.on(req).setOntModel(id, aware);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isStoreReasoned(ServletRequest req) {
|
||||||
|
String isStoreReasoned = ConfigurationProperties.getBean(req).getProperty(
|
||||||
|
"VitroConnection.DataSource.isStoreReasoned", "true");
|
||||||
|
return ("true".equals(isStoreReasoned));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
populatedObjectPropertyList.addAll(additions);
|
populatedObjectPropertyList.addAll(additions);
|
||||||
|
|
||||||
propertyList.addAll(populatedObjectPropertyList);
|
propertyList.addAll(populatedObjectPropertyList);
|
||||||
|
|
||||||
// If editing this page, merge in object properties applicable to the individual that are currently
|
// If editing this page, merge in object properties applicable to the individual that are currently
|
||||||
|
@ -95,7 +95,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
if (editing) {
|
if (editing) {
|
||||||
mergeAllPossibleObjectProperties(populatedObjectPropertyList, propertyList);
|
mergeAllPossibleObjectProperties(populatedObjectPropertyList, propertyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now do much the same with data properties: get the list of populated data properties, then add in placeholders for missing ones
|
// Now do much the same with data properties: get the list of populated data properties, then add in placeholders for missing ones
|
||||||
// rjy7 Currently we are getting the list of properties in one sparql query, then doing a separate query
|
// rjy7 Currently we are getting the list of properties in one sparql query, then doing a separate query
|
||||||
// to get values for each property. This could be optimized by doing a single query to get a map of properties to
|
// to get values for each property. This could be optimized by doing a single query to get a map of properties to
|
||||||
|
@ -105,11 +105,11 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
List<DataProperty> populatedDataPropertyList = subject
|
List<DataProperty> populatedDataPropertyList = subject
|
||||||
.getPopulatedDataPropertyList();
|
.getPopulatedDataPropertyList();
|
||||||
propertyList.addAll(populatedDataPropertyList);
|
propertyList.addAll(populatedDataPropertyList);
|
||||||
|
|
||||||
if (editing) {
|
if (editing) {
|
||||||
mergeAllPossibleDataProperties(propertyList);
|
mergeAllPossibleDataProperties(propertyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(propertyList);
|
sort(propertyList);
|
||||||
|
|
||||||
// Put the list into groups
|
// Put the list into groups
|
||||||
|
|
Loading…
Add table
Reference in a new issue