diff --git a/doc/list_view_configuration_guidelines.txt b/doc/list_view_configuration_guidelines.txt index 2ab75600b..2f11d4377 100644 --- a/doc/list_view_configuration_guidelines.txt +++ b/doc/list_view_configuration_guidelines.txt @@ -47,6 +47,7 @@ due to the possibility of incomplete data. Make sure the query does the followin display the local name in the absence of the linked individual. Alternatively, this can be retrieved in the template using the localname(uri) method. +### TO BE AMENDED - use uniongraph instead - Each assertion or set of optional assertions must reference a different graph variable, so that no requirement about which assertions are in the same graph is imposed (unless this is desired in a specific case). @@ -58,20 +59,16 @@ Query for collated property - Include a ?subclass variable, named as such, in the SELECT clause. If the ?subclass variable is missing, the property will be displayed without collation. -- ?subclass must be the first term in the ORDER BY clause +- ?subclass must be the first term in the ORDER BY clause. - Include the following in the WHERE clause, substituting in the relevant variables for ?infoResource and core:InformationResource: OPTIONAL { GRAPH ?g4 { ?subclass rdfs:subClassOf core:InformationResource } GRAPH ?g5 { ?infoResource a ?subclass } - FILTER (?g5 != <http://vitro.mannlib.cornell.edu/default/inferred-tbox> && - ?g5 != <http://vitro.mannlib.cornell.edu/default/vitro-kb-inf> ) } -The filter blocks the retrieval of inferred type statements, so that, for example, we get -subclass bibo:Book but not bibo:Document, assuming the latter is inferred. If both have been -asserted, we will get both. +- Postprocessing removes all but the most specific subclass value from the query result set. ---------------------- Datetimes in the query diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseObjectPropertyDataPostProcessor.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseObjectPropertyDataPostProcessor.java index 100bf6d86..dd67215e5 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseObjectPropertyDataPostProcessor.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseObjectPropertyDataPostProcessor.java @@ -35,13 +35,19 @@ public abstract class BaseObjectPropertyDataPostProcessor implements return; } - objectPropertyTemplateModel.removeDuplicates(data); - + processList(data); + for (Map map : data) { process(map); } } + /** Postprocessing that applies to the list as a whole - reordering, removing duplicates, etc. */ + protected void processList(List> data) { + objectPropertyTemplateModel.removeDuplicates(data); + } + + /** Postprocessing that applies to individual list items */ protected abstract void process(Map map); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/CollatedObjectPropertyTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/CollatedObjectPropertyTemplateModel.java index 93c1d7b28..aa72763c4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/CollatedObjectPropertyTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/CollatedObjectPropertyTemplateModel.java @@ -94,6 +94,7 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM return null; } + @Override protected void removeDuplicates(List> data) { filterSubclasses(data); } @@ -101,10 +102,7 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM /* * The query returns subclasses of a specific superclass that the object belongs to; for example, * in the case of authorInAuthorship, subclasses of core:InformationResource. Here we remove all but - * the most specific subclass for the object. This must precede BaseObjectPropertyDataPostProcess.removeDuplicates(), - * since that will arbitrarily remove all but the first result for a given object. - * RY Implementation alternative: roll this filtering into the removeDuplicates() method to reduce the number of times - * we need to iterate through the results; but at the cost of conceptual clarity. + * the most specific subclass for the object. */ private void filterSubclasses(List> statementData) { String objectVariableName = getObjectKey(); @@ -148,44 +146,8 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM log.debug("Data after subclass filtering"); logData(statementData); } - -// List> filteredList = new ArrayList>(); -// Set processedObjects = new HashSet(); -// Iterator> iOuter = statementData.iterator(); -// while (iOuter.hasNext()) { -//// for (Map map : statementData) { -// Map outerMap = (Map) iOuter.next(); -// String outerObjectUri = outerMap.get(objectVariableName); -// if (processedObjects.contains(outerObjectUri)) { -// continue; -// } -// processedObjects.add(outerObjectUri); -// String outerSubclass = outerMap.get(SUBCLASS_VARIABLE_NAME); -// if (outerSubclass == null) { -// continue; -// } -// List superclassUris = wdf.getVClassDao().getAllSuperClassURIs(outerSubclass); -//// List> dataForThisObject = new ArrayList>(); -// Iterator> iInner = statementData.iterator(); -// while (iInner.hasNext()) { -// Map innerMap = iInner.next(); -// if (innerMap == outerMap || innerMap.get(objectVariableName) != outerObjectUri) { -// continue; -// } -// String innerSubclass = innerMap.get(SUBCLASS_VARIABLE_NAME); -// if (superclassUris.contains(innerSubclass)) { -// -// } -// -// } -// -// } - - } - - // Collections.sort(mergedPropertyList,new PropertyRanker(vreq)); private class SubclassComparator implements Comparator> { private VClassDao vclassDao; @@ -226,10 +188,8 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM return 1; } - return 0; - - } - + return 0; + } } private Map> collate(String subjectUri, String propertyUri, diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java index f017362f7..fb5a9214f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java @@ -196,12 +196,12 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel String postprocessorName = config.postprocessor; if (postprocessorName == null) { - //return; postprocessorName = DEFAULT_POSTPROCESSOR; } try { Class postprocessorClass = Class.forName(postprocessorName); + // RY If class doesn't exist, use default postprocessor *** Constructor constructor = postprocessorClass.getConstructor(ObjectPropertyTemplateModel.class, WebappDaoFactory.class); ObjectPropertyDataPostProcessor postprocessor = (ObjectPropertyDataPostProcessor) constructor.newInstance(this, wdf); postprocessor.process(data);