improvements to superclass methods in VClassDaoJena to support VIVO-60

This commit is contained in:
brianjlowe 2013-06-24 16:47:46 -04:00
parent aa9be9469c
commit dae9c0c12f
9 changed files with 40 additions and 25 deletions

View file

@ -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;
}
}

View file

@ -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());

View file

@ -503,7 +503,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
List<VClass> allTypes = ind.getVClasses(false); // include indirect types
Set<String> allSuperclassURIs = new HashSet<String>();
for (VClass type : allTypes) {
String classURI = type.getURI();
if (classURI != null) {
@ -718,7 +718,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
: (op.getRange() == null && foundRanges[1] != null)
? foundRanges[1]
: op.getRange();
propInsts.add(getPropInstForPropertyAndRange(op, rangeRes, applicableProperties));
propInsts.add(getPropInstForPropertyAndRange(op, rangeRes, applicableProperties));
List<String> additionalFauxSubpropertyRangeURIs = getAdditionalFauxSubpropertyRangeURIsForPropertyURI(propertyURI);
for (String rangeURI : additionalFauxSubpropertyRangeURIs) {
if (getWebappDaoFactory().getVClassDao().isSubClassOf(rangeURI, rangeRes.getURI())) {

View file

@ -66,15 +66,21 @@ 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
protected OntModel getOntModel() {
return getOntModelSelector().getTBoxModel();
}
protected boolean isUnderlyingStoreReasoned() {
return this.isUnderlyingStoreReasoned;
}
/* ************************************************** */
@ -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();

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}
@ -212,6 +213,12 @@ public class RequestModelsPrep implements Filter {
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
public void destroy() {

View file

@ -86,7 +86,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
}
populatedObjectPropertyList.addAll(additions);
propertyList.addAll(populatedObjectPropertyList);
// 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) {
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
// 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
@ -105,11 +105,11 @@ public class GroupedPropertyList extends BaseTemplateModel {
List<DataProperty> populatedDataPropertyList = subject
.getPopulatedDataPropertyList();
propertyList.addAll(populatedDataPropertyList);
if (editing) {
mergeAllPossibleDataProperties(propertyList);
}
sort(propertyList);
// Put the list into groups