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 String getCustomListConfigFileName(ObjectProperty objectProperty);
public String getCustomListViewConfigFileName(ObjectProperty objectProperty);
}

View file

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

View file

@ -82,15 +82,15 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
static {
List<String> namespaceFilters = new ArrayList<String>();
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 =
PREFIXES + "\n" +
"SELECT DISTINCT ?property WHERE { \n" +
" GRAPH ?g { ?subject ?property ?object } \n" +
" GRAPH ?h { ?property rdf:type owl:DatatypeProperty } \n" +
" GRAPH ?g1 { ?subject ?property ?object } \n" +
" GRAPH ?g2 { ?property rdf:type owl:DatatypeProperty } \n" +
propertyFilters +
"}";

View file

@ -72,20 +72,20 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
static {
List<String> namespaceFilters = new ArrayList<String>();
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
namespaceFilters.add("( ?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#primaryLink> ||" +
"?property = <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#additionalLink> ||" +
"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 =
PREFIXES + "\n" +
"SELECT DISTINCT ?property WHERE { \n" +
" GRAPH ?g { ?subject ?property ?object } \n" +
" GRAPH ?h { ?property rdf:type owl:ObjectProperty } \n" +
" GRAPH ?g1 { ?subject ?property ?object } \n" +
" GRAPH ?g2 { ?property rdf:type owl:ObjectProperty } \n" +
propertyFilters +
"}";
@ -896,6 +896,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
QuerySolution soln = results.next();
Resource resource = soln.getResource("property");
String uri = resource.getURI();
log.debug("Found populated object property " + uri + " for individual " + subjectUri);
ObjectProperty property = getObjectPropertyByURI(uri);
properties.add(property);
}
@ -903,26 +904,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
}
@Override
public String getCustomListConfigFileName(ObjectProperty op) {
public String getCustomListViewConfigFileName(ObjectProperty op) {
if (customListViewConfigFileMap == null) {
customListViewConfigFileMap = new HashMap<ObjectProperty, String>();
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);
ResultSet results = qexec.execSelect();
while (results.hasNext()) {

View file

@ -44,7 +44,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
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 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#>";

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,
// so we cannot just rely on getting that list.
List<ObjectProperty> objectPropertyList = subject.getPopulatedObjectPropertyList();
for (ObjectProperty op : objectPropertyList) {
propertyList.add(op);
}
propertyList.addAll(objectPropertyList);
// 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.
@ -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
// two working in parallel.
List<DataProperty> dataPropertyList = subject.getPopulatedDataPropertyList();
for (DataProperty dp : dataPropertyList) {
propertyList.add(dp);
}
propertyList.addAll(dataPropertyList);
if (policyHelper != null) {
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
} else if (p.getGroupURI()==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)) {
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

View file

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