NIHVIVO-1333 Revert changes from r6573, and move namespace filtering on properties into the sparql query
This commit is contained in:
parent
fb855abaf1
commit
90c710400b
22 changed files with 197 additions and 331 deletions
|
@ -46,12 +46,6 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
|
|||
List<ObjectProperty> getObjectPropertyList();
|
||||
void setPropertyList(List<ObjectProperty> propertyList);
|
||||
|
||||
/*
|
||||
* RY These duplicate the functionality of getObjectPropertyList(),
|
||||
* but get data through a sparql query rather than dao methods. They
|
||||
* use a different field so as not to disrupt any code that depends on
|
||||
* the propertyList field. The two approaches should be integrated at a later point.
|
||||
*/
|
||||
List<ObjectProperty> getPopulatedObjectPropertyList();
|
||||
void setPopulatedObjectPropertyList(List<ObjectProperty> propertyList);
|
||||
|
||||
|
@ -61,12 +55,6 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
|
|||
List<DataProperty> getDataPropertyList();
|
||||
void setDatatypePropertyList(List<DataProperty> datatypePropertyList);
|
||||
|
||||
/*
|
||||
* RY These duplicate the functionality of getDataPropertyList(),
|
||||
* but get data through a sparql query rather than dao methods. They
|
||||
* use a different field so as not to disrupt any code that depends on
|
||||
* the datatypePropertyList field. The two approaches should be integrated at a later point.
|
||||
*/
|
||||
List<DataProperty> getPopulatedDataPropertyList();
|
||||
void setPopulatedDataPropertyList(List<DataProperty> dataPropertyList);
|
||||
|
||||
|
|
|
@ -36,4 +36,7 @@ public interface DataPropertyDao extends PropertyDao {
|
|||
|
||||
boolean annotateDataPropertyAsExternalIdentifier(String dataPropertyURI);
|
||||
|
||||
public List<DataProperty> getDataPropertyList(Individual subject);
|
||||
|
||||
public List<DataProperty> getDataPropertyList(String subjectUri);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
|
||||
public interface DataPropertyListDao extends PropertyListDao {
|
||||
|
||||
public List<DataProperty> getDataPropertyList(Individual subject);
|
||||
|
||||
public List<DataProperty> getDataPropertyList(String subjectUri);
|
||||
|
||||
}
|
|
@ -52,4 +52,7 @@ public interface ObjectPropertyDao extends PropertyDao {
|
|||
|
||||
List <ObjectProperty> getRootObjectProperties();
|
||||
|
||||
public List<ObjectProperty> getObjectPropertyList(Individual subject);
|
||||
|
||||
public List<ObjectProperty> getObjectPropertyList(String subjectUri);
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
|
||||
public interface ObjectPropertyListDao extends PropertyListDao {
|
||||
|
||||
public List<ObjectProperty> getObjectPropertyList(Individual subject);
|
||||
|
||||
public List<ObjectProperty> getObjectPropertyList(String subjectUri);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao;
|
||||
|
||||
public interface PropertyListDao {
|
||||
|
||||
// Get rid of this interface if it doesn't declare any methods
|
||||
}
|
|
@ -132,8 +132,4 @@ public interface WebappDaoFactory {
|
|||
public NamespaceDao getNamespaceDao();
|
||||
|
||||
public PropertyInstanceDao getPropertyInstanceDao();
|
||||
|
||||
public ObjectPropertyListDao getObjectPropertyListDao();
|
||||
|
||||
public DataPropertyListDao getDataPropertyListDao();
|
||||
}
|
||||
|
|
|
@ -192,4 +192,16 @@ class DataPropertyDaoFiltering extends BaseFiltering implements DataPropertyDao{
|
|||
return innerDataPropertyDao.getClassesWithRestrictionOnProperty(propertyURI);
|
||||
}
|
||||
|
||||
@Override
|
||||
// This may need to be filtered at some point.
|
||||
public List<DataProperty> getDataPropertyList(Individual subject) {
|
||||
return innerDataPropertyDao.getDataPropertyList(subject);
|
||||
}
|
||||
|
||||
@Override
|
||||
// This may need to be filtered at some point.
|
||||
public List<DataProperty> getDataPropertyList(String subjectUri) {
|
||||
return innerDataPropertyDao.getDataPropertyList(subjectUri);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,8 +13,6 @@ import java.util.Map;
|
|||
|
||||
import net.sf.jga.algorithms.Filter;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -29,7 +27,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ObjectPropertyListDaoJena;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
|
||||
/**
|
||||
|
@ -41,9 +38,6 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
|||
*
|
||||
*/
|
||||
public class IndividualFiltering implements Individual {
|
||||
|
||||
protected static final Log log = LogFactory.getLog(IndividualFiltering.class);
|
||||
|
||||
private final Individual _innerIndividual;
|
||||
private final VitroFilters _filters;
|
||||
|
||||
|
|
|
@ -203,4 +203,15 @@ class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectProperty
|
|||
return innerObjectPropertyDao.getClassesWithRestrictionOnProperty(propertyURI);
|
||||
}
|
||||
|
||||
@Override
|
||||
// This may need to be filtered at some point.
|
||||
public List<ObjectProperty> getObjectPropertyList(Individual subject) {
|
||||
return innerObjectPropertyDao.getObjectPropertyList(subject);
|
||||
}
|
||||
|
||||
@Override
|
||||
// This may need to be filtered at some point.
|
||||
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
|
||||
return innerObjectPropertyDao.getObjectPropertyList(subjectUri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.Set;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyListDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.FlagDao;
|
||||
|
@ -20,7 +19,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyListDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PortalDao;
|
||||
|
@ -216,14 +214,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
|
|||
return innerWebappDaoFactory.getPortalDao();
|
||||
}
|
||||
|
||||
public ObjectPropertyListDao getObjectPropertyListDao() {
|
||||
return innerWebappDaoFactory.getObjectPropertyListDao();
|
||||
}
|
||||
|
||||
public DataPropertyListDao getDataPropertyListDao() {
|
||||
return innerWebappDaoFactory.getDataPropertyListDao();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,26 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
|
||||
protected static final Log log = LogFactory.getLog(DataPropertyDaoJena.class.getName());
|
||||
|
||||
protected static final String dataPropertyQueryString =
|
||||
PREFIXES + "\n" +
|
||||
"SELECT DISTINCT ?property WHERE { \n" +
|
||||
//" GRAPH ?g {\n" +
|
||||
" ?subject ?property ?object . \n" +
|
||||
" ?property rdf:type owl:DatatypeProperty . \n" +
|
||||
propertyFilters +
|
||||
//" }\n" +
|
||||
"}";
|
||||
|
||||
static protected Query dataPropertyQuery;
|
||||
static {
|
||||
try {
|
||||
dataPropertyQuery = QueryFactory.create(dataPropertyQueryString);
|
||||
} catch(Throwable th){
|
||||
log.error("could not create SPARQL query for dataPropertyQueryString " + th.getMessage());
|
||||
log.error(dataPropertyQueryString);
|
||||
}
|
||||
}
|
||||
|
||||
private class DataPropertyRanker implements Comparator {
|
||||
public int compare (Object o1, Object o2) {
|
||||
DataProperty dp1 = (DataProperty) o1;
|
||||
|
@ -688,4 +708,32 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
return rootProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataProperty> getDataPropertyList(Individual subject) {
|
||||
return getDataPropertyList(subject.getURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
/*
|
||||
* SPARQL-based method for getting the individual's data properties.
|
||||
* Ideally this implementation should replace the existing way of getting
|
||||
* the data property list, but the consequences of this may be far-reaching,
|
||||
* so we are implementing a new method now and will merge the old approach
|
||||
* into the new one in a future release.
|
||||
*/
|
||||
public List<DataProperty> getDataPropertyList(String subjectUri) {
|
||||
log.debug("dataPropertyQueryString:\n" + dataPropertyQueryString);
|
||||
log.debug("dataPropertyQuery:\n" + dataPropertyQuery);
|
||||
ResultSet results = getPropertyQueryResults(subjectUri, dataPropertyQuery);
|
||||
List<DataProperty> properties = new ArrayList<DataProperty>();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution sol = results.next();
|
||||
Resource resource = sol.getResource("property");
|
||||
String uri = resource.getURI();
|
||||
DataProperty property = getDataPropertyByURI(uri);
|
||||
properties.add(property);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyListDao;
|
||||
|
||||
public class DataPropertyListDaoJena extends PropertyListDaoJena implements
|
||||
DataPropertyListDao {
|
||||
|
||||
protected static final Log log = LogFactory.getLog(DataPropertyListDaoJena.class);
|
||||
|
||||
protected static final String dataPropertyQueryString =
|
||||
PREFIXES + "\n" +
|
||||
"SELECT DISTINCT ?predicate WHERE { \n" +
|
||||
//" GRAPH ?g {\n" +
|
||||
" ?subject ?predicate ?object . \n" +
|
||||
" ?predicate rdf:type owl:DatatypeProperty . \n" +
|
||||
//" }\n" +
|
||||
"}" +
|
||||
"ORDER BY ?predicate\n";
|
||||
|
||||
static protected Query dataPropertyQuery;
|
||||
static {
|
||||
try {
|
||||
dataPropertyQuery = QueryFactory.create(dataPropertyQueryString);
|
||||
} catch(Throwable th){
|
||||
log.error("could not create SPARQL query for dataPropertyQueryString " + th.getMessage());
|
||||
log.error(dataPropertyQueryString);
|
||||
}
|
||||
}
|
||||
|
||||
public DataPropertyListDaoJena(WebappDaoFactoryJena wadf) {
|
||||
super(wadf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataProperty> getDataPropertyList(Individual subject) {
|
||||
return getDataPropertyList(subject.getURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataProperty> getDataPropertyList(String subjectUri) {
|
||||
log.debug("dataPropertyQuery:\n" + dataPropertyQuery);
|
||||
ResultSet results = getPropertyQueryResults(subjectUri, dataPropertyQuery);
|
||||
List<DataProperty> properties = new ArrayList<DataProperty>();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution sol = results.next();
|
||||
Resource resource = sol.getResource("predicate");
|
||||
// This is a hack to throw out properties in the vitro, rdf, rdfs, and owl namespaces.
|
||||
// It will be implemented in a better way in v1.3 (Editing and Display Configuration).
|
||||
// It must be done here rather than in PropertyList or PropertyListBuilder, because
|
||||
// those properties must be removed for the IndividualFiltering object.
|
||||
if ( ! EXCLUDED_NAMESPACES.contains(resource.getNameSpace())) {
|
||||
String uri = resource.getURI();
|
||||
DataPropertyDao dpDao = getWebappDaoFactory().getDataPropertyDao();
|
||||
DataProperty property = dpDao.getDataPropertyByURI(uri);
|
||||
properties.add(property);
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
|
@ -740,7 +740,7 @@ public class IndividualJena extends IndividualImpl implements Individual {
|
|||
@Override
|
||||
public List<ObjectProperty> getPopulatedObjectPropertyList() {
|
||||
if (populatedObjectPropertyList == null) {
|
||||
populatedObjectPropertyList = webappDaoFactory.getObjectPropertyListDao().getObjectPropertyList(this);
|
||||
populatedObjectPropertyList = webappDaoFactory.getObjectPropertyDao().getObjectPropertyList(this);
|
||||
}
|
||||
return populatedObjectPropertyList;
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ public class IndividualJena extends IndividualImpl implements Individual {
|
|||
@Override
|
||||
public List<DataProperty> getPopulatedDataPropertyList() {
|
||||
if (populatedDataPropertyList == null) {
|
||||
populatedDataPropertyList = webappDaoFactory.getDataPropertyListDao().getDataPropertyList(this);
|
||||
populatedDataPropertyList = webappDaoFactory.getDataPropertyDao().getDataPropertyList(this);
|
||||
}
|
||||
return populatedDataPropertyList;
|
||||
}
|
||||
|
|
|
@ -884,7 +884,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
@Override
|
||||
public List<ObjectProperty> getPopulatedObjectPropertyList() {
|
||||
if (populatedObjectPropertyList == null) {
|
||||
populatedObjectPropertyList = webappDaoFactory.getObjectPropertyListDao().getObjectPropertyList(this);
|
||||
populatedObjectPropertyList = webappDaoFactory.getObjectPropertyDao().getObjectPropertyList(this);
|
||||
}
|
||||
return populatedObjectPropertyList;
|
||||
}
|
||||
|
@ -938,7 +938,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
@Override
|
||||
public List<DataProperty> getPopulatedDataPropertyList() {
|
||||
if (populatedDataPropertyList == null) {
|
||||
populatedDataPropertyList = webappDaoFactory.getDataPropertyListDao().getDataPropertyList(this);
|
||||
populatedDataPropertyList = webappDaoFactory.getDataPropertyDao().getDataPropertyList(this);
|
||||
}
|
||||
return populatedDataPropertyList;
|
||||
}
|
||||
|
|
|
@ -872,7 +872,7 @@ public class IndividualSDB2 extends IndividualImpl implements Individual {
|
|||
@Override
|
||||
public List<ObjectProperty> getPopulatedObjectPropertyList() {
|
||||
if (populatedObjectPropertyList == null) {
|
||||
populatedObjectPropertyList = webappDaoFactory.getObjectPropertyListDao().getObjectPropertyList(this);
|
||||
populatedObjectPropertyList = webappDaoFactory.getObjectPropertyDao().getObjectPropertyList(this);
|
||||
}
|
||||
return populatedObjectPropertyList;
|
||||
}
|
||||
|
@ -923,14 +923,6 @@ public class IndividualSDB2 extends IndividualImpl implements Individual {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataProperty> getPopulatedDataPropertyList() {
|
||||
if (populatedDataPropertyList == null) {
|
||||
populatedDataPropertyList = webappDaoFactory.getDataPropertyListDao().getDataPropertyList(this);
|
||||
}
|
||||
return populatedDataPropertyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,DataProperty> getDataPropertyMap() {
|
||||
if (this.dataPropertyMap != null) {
|
||||
|
|
|
@ -48,6 +48,26 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
|||
public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectPropertyDao {
|
||||
private static final Log log = LogFactory.getLog(ObjectPropertyDaoJena.class.getName());
|
||||
|
||||
protected static final String objectPropertyQueryString =
|
||||
PREFIXES + "\n" +
|
||||
"SELECT DISTINCT ?property WHERE { \n" +
|
||||
//" GRAPH ?g {\n" +
|
||||
" ?subject ?property ?object . \n" +
|
||||
" ?property rdf:type owl:ObjectProperty . \n" +
|
||||
propertyFilters +
|
||||
//" }\n" +
|
||||
"}";
|
||||
|
||||
static protected Query objectPropertyQuery;
|
||||
static {
|
||||
try {
|
||||
objectPropertyQuery = QueryFactory.create(objectPropertyQueryString);
|
||||
} catch(Throwable th){
|
||||
log.error("could not create SPARQL query for objectPropertyQueryString " + th.getMessage());
|
||||
log.error(objectPropertyQueryString);
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectPropertyDaoJena(WebappDaoFactoryJena wadf) {
|
||||
super(wadf);
|
||||
}
|
||||
|
@ -804,4 +824,33 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ObjectProperty> getObjectPropertyList(Individual subject) {
|
||||
return getObjectPropertyList(subject.getURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
/*
|
||||
* SPARQL-based method for getting the individual's object properties.
|
||||
* Ideally this implementation should replace the existing way of getting
|
||||
* the object property list, but the consequences of this may be far-reaching,
|
||||
* so we are implementing a new method now and will merge the old approach
|
||||
* into the new one in a future release.
|
||||
*/
|
||||
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
|
||||
log.debug("objectPropertyQueryString:\n" + objectPropertyQueryString);
|
||||
log.debug("objectPropertyQuery:\n" + objectPropertyQuery);
|
||||
ResultSet results = getPropertyQueryResults(subjectUri, objectPropertyQuery);
|
||||
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution sol = results.next();
|
||||
Resource resource = sol.getResource("property");
|
||||
String uri = resource.getURI();
|
||||
ObjectProperty property = getObjectPropertyByURI(uri);
|
||||
properties.add(property);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyListDao;
|
||||
|
||||
public class ObjectPropertyListDaoJena extends PropertyListDaoJena implements
|
||||
ObjectPropertyListDao {
|
||||
|
||||
protected static final Log log = LogFactory.getLog(ObjectPropertyListDaoJena.class);
|
||||
|
||||
protected static final String objectPropertyQueryString =
|
||||
PREFIXES + "\n" +
|
||||
"SELECT DISTINCT ?predicate WHERE { \n" +
|
||||
//" GRAPH ?g {\n" +
|
||||
" ?subject ?predicate ?object . \n" +
|
||||
" ?predicate rdf:type owl:ObjectProperty . \n" +
|
||||
//" }\n" +
|
||||
"}" +
|
||||
"ORDER BY ?predicate\n";
|
||||
|
||||
protected static Query objectPropertyQuery;
|
||||
static {
|
||||
try {
|
||||
objectPropertyQuery = QueryFactory.create(objectPropertyQueryString);
|
||||
} catch(Throwable th){
|
||||
log.error("could not create SPARQL query for objectPropertyQueryString " + th.getMessage());
|
||||
log.error(objectPropertyQueryString);
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectPropertyListDaoJena(WebappDaoFactoryJena wadf) {
|
||||
super(wadf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ObjectProperty> getObjectPropertyList(Individual subject) {
|
||||
return getObjectPropertyList(subject.getURI());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ObjectProperty> getObjectPropertyList(String subjectUri) {
|
||||
log.debug("objectPropertyQuery:\n" + objectPropertyQuery);
|
||||
ResultSet results = getPropertyQueryResults(subjectUri, objectPropertyQuery);
|
||||
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution sol = results.next();
|
||||
Resource resource = sol.getResource("predicate");
|
||||
// This is a hack to throw out properties in the vitro, rdf, rdfs, and owl namespaces.
|
||||
// It will be implemented in a better way in v1.3 (Editing and Display Configuration).
|
||||
// It must be done here rather than in PropertyList or PropertyListBuilder, because
|
||||
// those properties must be removed for the IndividualFiltering object.
|
||||
if ( ! EXCLUDED_NAMESPACES.contains(resource.getNameSpace())) {
|
||||
String uri = resource.getURI();
|
||||
ObjectPropertyDao opDao = getWebappDaoFactory().getObjectPropertyDao();
|
||||
ObjectProperty property = opDao.getObjectPropertyByURI(uri);
|
||||
properties.add(property);
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
|
@ -41,6 +41,34 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
|
||||
protected static final Log log = LogFactory.getLog(PropertyDaoJena.class.getName());
|
||||
|
||||
protected static final String PREFIXES =
|
||||
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
|
||||
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||
"PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
|
||||
"PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>";
|
||||
|
||||
/* This may be the intent behind JenaBaseDao.NONUSER_NAMESPACES, but that
|
||||
* value does not contain all of these namespaces.
|
||||
*/
|
||||
protected static final List<String> EXCLUDED_NAMESPACES = Arrays.asList(
|
||||
"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#",
|
||||
"http://vitro.mannlib.cornell.edu/ns/vitro/public#",
|
||||
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
||||
"http://www.w3.org/2000/01/rdf-schema#",
|
||||
"http://www.w3.org/2002/07/owl#"
|
||||
);
|
||||
|
||||
/*
|
||||
* This is a hack to throw out properties in the vitro, rdf, rdfs, and owl namespaces.
|
||||
* It will be implemented in a better way in v1.3 (Editing and Display Configuration).
|
||||
*/
|
||||
protected static String propertyFilters = "";
|
||||
static {
|
||||
for (String s : EXCLUDED_NAMESPACES) {
|
||||
propertyFilters += "FILTER (afn:namespace(?property) != \"" + s + "\") \n";
|
||||
}
|
||||
}
|
||||
|
||||
public PropertyDaoJena(WebappDaoFactoryJena wadf) {
|
||||
super(wadf);
|
||||
}
|
||||
|
@ -378,4 +406,14 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
return classSet;
|
||||
}
|
||||
|
||||
protected ResultSet getPropertyQueryResults(String subjectUri, Query query) {
|
||||
log.debug("SPARQL query:\n" + query.toString());
|
||||
// Bind the subject's uri to the ?subject query term
|
||||
QuerySolutionMap subjectBinding = new QuerySolutionMap();
|
||||
subjectBinding.add("subject", ResourceFactory.createResource(subjectUri));
|
||||
|
||||
// Run the SPARQL query to get the properties
|
||||
QueryExecution qexec = QueryExecutionFactory.create(query, getOntModelSelector().getFullModel(), subjectBinding);
|
||||
return qexec.execSelect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.QuerySolutionMap;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyListDao;
|
||||
|
||||
public class PropertyListDaoJena extends JenaBaseDao implements PropertyListDao {
|
||||
|
||||
protected static final Log log = LogFactory.getLog(PropertyListDaoJena.class);
|
||||
|
||||
protected static final String PREFIXES =
|
||||
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
|
||||
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
|
||||
"PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
|
||||
"PREFIX afn: <http://jena.hp1.hp.com/ARQ/function#>";
|
||||
|
||||
/* This may be the intent behind JenaBaseDao.NONUSER_NAMESPACES, but that
|
||||
* value does not contain all of these namespaces.
|
||||
*/
|
||||
protected static final List<String> EXCLUDED_NAMESPACES = Arrays.asList(
|
||||
"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#",
|
||||
"http://vitro.mannlib.cornell.edu/ns/vitro/public#",
|
||||
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
||||
"http://www.w3.org/2000/01/rdf-schema#",
|
||||
"http://www.w3.org/2002/07/owl#"
|
||||
);
|
||||
|
||||
public PropertyListDaoJena(WebappDaoFactoryJena wadf) {
|
||||
super(wadf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OntModel getOntModel() {
|
||||
return getOntModelSelector().getFullModel();
|
||||
}
|
||||
|
||||
protected ResultSet getPropertyQueryResults(String subjectUri, Query query) {
|
||||
log.debug("SPARQL query:\n" + query.toString());
|
||||
// Bind the subject's uri to the ?subject query term
|
||||
QuerySolutionMap subjectBinding = new QuerySolutionMap();
|
||||
subjectBinding.add("subject", ResourceFactory.createResource(subjectUri));
|
||||
|
||||
// Run the SPARQL query to get the properties
|
||||
QueryExecution qexec = QueryExecutionFactory.create(query, getOntModelSelector().getFullModel(), subjectBinding);
|
||||
return qexec.execSelect();
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.hp.hpl.jena.iri.IRI;
|
||||
import com.hp.hpl.jena.iri.IRIFactory;
|
||||
|
@ -29,10 +30,10 @@ import com.hp.hpl.jena.vocabulary.OWL;
|
|||
import com.hp.hpl.jena.vocabulary.RDF;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyListDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.FlagDao;
|
||||
|
@ -43,7 +44,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyListDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PortalDao;
|
||||
|
@ -549,22 +549,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
|||
return propertyInstanceDao;
|
||||
}
|
||||
|
||||
private ObjectPropertyListDao objectPropertyListDao = null;
|
||||
public ObjectPropertyListDao getObjectPropertyListDao() {
|
||||
if (objectPropertyListDao == null) {
|
||||
objectPropertyListDao = new ObjectPropertyListDaoJena(this);
|
||||
}
|
||||
return objectPropertyListDao;
|
||||
}
|
||||
|
||||
private DataPropertyListDao DataPropertyListDao = null;
|
||||
public DataPropertyListDao getDataPropertyListDao() {
|
||||
if (DataPropertyListDao == null) {
|
||||
DataPropertyListDao = new DataPropertyListDaoJena(this);
|
||||
}
|
||||
return DataPropertyListDao;
|
||||
}
|
||||
|
||||
protected VClassDao vClassDao = null;
|
||||
public VClassDao getVClassDao() {
|
||||
if( vClassDao == null )
|
||||
|
|
|
@ -38,7 +38,13 @@ public class PropertyList extends BaseTemplateModel {
|
|||
|
||||
protected void addObjectProperties(List<ObjectProperty> propertyList) {
|
||||
for (ObjectProperty op : propertyList) {
|
||||
// This is a hack to throw out properties in the vitro, rdf, rdfs, and owl namespaces.
|
||||
// It will be implemented in a better way in v1.3 (Editing and Display Configuration).
|
||||
//if (! EXCLUDED_NAMESPACES.contains(op.getNamespace())) {
|
||||
add(op);
|
||||
//} else {
|
||||
// log.debug("Excluded " + op.getURI() + " from displayed property list on the basis of namespace");
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,6 +136,20 @@ public class PropertyList extends BaseTemplateModel {
|
|||
}
|
||||
}
|
||||
|
||||
// private void addUnique(Property p) {
|
||||
// if (! contains(p)) {
|
||||
// add(p);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected void add(Property p) {
|
||||
// if (p instanceof ObjectProperty) {
|
||||
// add((ObjectProperty) p);
|
||||
// } else if (p instanceof DataProperty) {
|
||||
// add((DataProperty) p);
|
||||
// }
|
||||
// }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void sort(VitroRequest vreq) {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue