A few minor refactorings, adding debugging output, etc.

This commit is contained in:
rjy7 2011-01-14 20:32:50 +00:00
parent e446c8144c
commit 13cfc80bc2
7 changed files with 19 additions and 38 deletions

View file

@ -56,5 +56,5 @@ public interface ObjectPropertyDao extends PropertyDao {
public List<ObjectProperty> getObjectPropertyList(String subjectUri); public List<ObjectProperty> getObjectPropertyList(String subjectUri);
public String getCustomListConfigFileName(ObjectProperty objectProperty); public String getCustomListViewConfigFileName(ObjectProperty objectProperty);
} }

View file

@ -216,7 +216,7 @@ class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectProperty
} }
@Override @Override
public String getCustomListConfigFileName(ObjectProperty objectProperty) { public String getCustomListViewConfigFileName(ObjectProperty objectProperty) {
return innerObjectPropertyDao.getCustomListConfigFileName(objectProperty); return innerObjectPropertyDao.getCustomListViewConfigFileName(objectProperty);
} }
} }

View file

@ -82,15 +82,15 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
static { static {
List<String> namespaceFilters = new ArrayList<String>(); List<String> namespaceFilters = new ArrayList<String>();
for (String s : EXCLUDED_NAMESPACES) { for (String s : EXCLUDED_NAMESPACES) {
namespaceFilters.add("afn:namespace(?property) != \"" + s + "\""); namespaceFilters.add("(afn:namespace(?property) != \"" + s + "\")");
} }
propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && \n") + ")\n"; propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && ") + ")\n";
} }
protected static final String dataPropertyQueryString = protected static final String dataPropertyQueryString =
PREFIXES + "\n" + PREFIXES + "\n" +
"SELECT DISTINCT ?property WHERE { \n" + "SELECT DISTINCT ?property WHERE { \n" +
" GRAPH ?g { ?subject ?property ?object } \n" + " GRAPH ?g1 { ?subject ?property ?object } \n" +
" GRAPH ?h { ?property rdf:type owl:DatatypeProperty } \n" + " GRAPH ?g2 { ?property rdf:type owl:DatatypeProperty } \n" +
propertyFilters + propertyFilters +
"}"; "}";

View file

@ -72,20 +72,20 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
static { static {
List<String> namespaceFilters = new ArrayList<String>(); List<String> namespaceFilters = new ArrayList<String>();
for (String s : EXCLUDED_NAMESPACES) { for (String s : EXCLUDED_NAMESPACES) {
namespaceFilters.add("afn:namespace(?property) != \"" + s + "\""); namespaceFilters.add("(afn:namespace(?property) != \"" + s + "\")");
} }
// A hack to include the vitro:primaryLink and vitro:additionalLink properties in the list // A hack to include the vitro:primaryLink and vitro:additionalLink properties in the list
namespaceFilters.add("( ?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#primaryLink> ||" + namespaceFilters.add("( ?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#primaryLink> ||" +
"?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#additionalLink> ||" + "?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#additionalLink> ||" +
"afn:namespace(?property) != \"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#\" )"); "afn:namespace(?property) != \"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#\" )");
propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && \n") + ")\n"; propertyFilters = "FILTER (" + StringUtils.join(namespaceFilters, " && ") + ")\n";
} }
protected static final String objectPropertyQueryString = protected static final String objectPropertyQueryString =
PREFIXES + "\n" + PREFIXES + "\n" +
"SELECT DISTINCT ?property WHERE { \n" + "SELECT DISTINCT ?property WHERE { \n" +
" GRAPH ?g { ?subject ?property ?object } \n" + " GRAPH ?g1 { ?subject ?property ?object } \n" +
" GRAPH ?h { ?property rdf:type owl:ObjectProperty } \n" + " GRAPH ?g2 { ?property rdf:type owl:ObjectProperty } \n" +
propertyFilters + propertyFilters +
"}"; "}";
@ -896,6 +896,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
QuerySolution soln = results.next(); QuerySolution soln = results.next();
Resource resource = soln.getResource("property"); Resource resource = soln.getResource("property");
String uri = resource.getURI(); String uri = resource.getURI();
log.debug("Found populated object property " + uri + " for individual " + subjectUri);
ObjectProperty property = getObjectPropertyByURI(uri); ObjectProperty property = getObjectPropertyByURI(uri);
properties.add(property); properties.add(property);
} }
@ -903,26 +904,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
} }
@Override @Override
public String getCustomListConfigFileName(ObjectProperty op) { public String getCustomListViewConfigFileName(ObjectProperty op) {
if (customListViewConfigFileMap == null) { if (customListViewConfigFileMap == null) {
customListViewConfigFileMap = new HashMap<ObjectProperty, String>(); customListViewConfigFileMap = new HashMap<ObjectProperty, String>();
OntModel displayModel = getOntModelSelector().getDisplayModel(); OntModel displayModel = getOntModelSelector().getDisplayModel();
// Property listViewConfigProp = displayModel.getProperty(VitroVocabulary.DISPLAY + "customListViewConfigurationFile");
// ResIterator resources = displayModel.listResourcesWithProperty(listViewConfigProp);
// while (resources.hasNext()) {
// Resource resource = resources.next();
// ObjectProperty prop = getObjectPropertyByURI(resource.getURI());
// NodeIterator nodes = displayModel.listObjectsOfProperty(resource, listViewConfigProp);
// if (nodes.hasNext()) {
// RDFNode node = nodes.next(); // there should be at most one value; just get the first one
// if (node.isLiteral()) {
// String configFileName = ((Literal)node).getLexicalForm();
// customListViewConfigFiles.put(prop, configFileName);
// }
// }
// }
QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel); QueryExecution qexec = QueryExecutionFactory.create(listViewConfigFileQuery, displayModel);
ResultSet results = qexec.execSelect(); ResultSet results = qexec.execSelect();
while (results.hasNext()) { while (results.hasNext()) {

View file

@ -44,7 +44,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
protected static final String PREFIXES = protected static final String PREFIXES =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "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 vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" + "PREFIX owl: <http://www.w3.org/2002/07/owl#> \n" +
"PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>"; "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>";

View file

@ -70,9 +70,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
// This may include properties that are not defined as "possible properties" for a subject of this class, // This may include properties that are not defined as "possible properties" for a subject of this class,
// so we cannot just rely on getting that list. // so we cannot just rely on getting that list.
List<ObjectProperty> objectPropertyList = subject.getPopulatedObjectPropertyList(); List<ObjectProperty> objectPropertyList = subject.getPopulatedObjectPropertyList();
for (ObjectProperty op : objectPropertyList) { propertyList.addAll(objectPropertyList);
propertyList.add(op);
}
// 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
// unpopulated, so the properties are displayed to allow statements to be added to these properties. // unpopulated, so the properties are displayed to allow statements to be added to these properties.
@ -88,9 +86,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
// can be customized and thus differ from property to property. So it's easier for now to keep the // can be customized and thus differ from property to property. So it's easier for now to keep the
// two working in parallel. // two working in parallel.
List<DataProperty> dataPropertyList = subject.getPopulatedDataPropertyList(); List<DataProperty> dataPropertyList = subject.getPopulatedDataPropertyList();
for (DataProperty dp : dataPropertyList) { propertyList.addAll(dataPropertyList);
propertyList.add(dp);
}
if (policyHelper != null) { if (policyHelper != null) {
mergeAllPossibleDataProperties(propertyList); mergeAllPossibleDataProperties(propertyList);
@ -279,10 +275,10 @@ public class GroupedPropertyList extends BaseTemplateModel {
// If the property is not assigned to any group, add it to the group for unassigned properties // If the property is not assigned to any group, add it to the group for unassigned properties
} else if (p.getGroupURI()==null) { } else if (p.getGroupURI()==null) {
if (groupForUnassignedProperties!=null) { if (groupForUnassignedProperties!=null) {
// RY How could it happen that it's already in the group? Maybe we can remove this case. // RY How could it happen that it's already in the group? Maybe we can remove this test.
if (!alreadyOnPropertyList(groupForUnassignedProperties.getPropertyList(),p)) { if (!alreadyOnPropertyList(groupForUnassignedProperties.getPropertyList(),p)) {
groupForUnassignedProperties.getPropertyList().add(p); groupForUnassignedProperties.getPropertyList().add(p);
log.debug("adding property "+p.getLabel()+" to group for unassigned propertiues"); log.debug("adding property "+p.getLabel()+" to group for unassigned properties");
} }
} }
// Otherwise, if the property is assigned to this group, add it to the group if it's not already there // Otherwise, if the property is assigned to this group, add it to the group if it's not already there

View file

@ -238,7 +238,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
// Get the custom config filename // Get the custom config filename
WebappDaoFactory wdf = vreq.getWebappDaoFactory(); WebappDaoFactory wdf = vreq.getWebappDaoFactory();
ObjectPropertyDao opDao = wdf.getObjectPropertyDao(); ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
String configFileName = opDao.getCustomListConfigFileName(op); String configFileName = opDao.getCustomListViewConfigFileName(op);
if (configFileName == null) { // no custom config; use default config if (configFileName == null) { // no custom config; use default config
configFileName = getDefaultConfigFileName(); configFileName = getDefaultConfigFileName();
} }