NIHVIVO-1859, NIHVIVO-1881 Comments and documentation on subclass collation of list views
This commit is contained in:
parent
e8c1c83aad
commit
96d7e2fae8
4 changed files with 16 additions and 53 deletions
|
@ -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
|
display the local name in the absence of the linked individual. Alternatively, this can be
|
||||||
retrieved in the template using the localname(uri) method.
|
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
|
- 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
|
no requirement about which assertions are in the same graph is imposed (unless this is desired
|
||||||
in a specific case).
|
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
|
- Include a ?subclass variable, named as such, in the SELECT clause. If the ?subclass variable
|
||||||
is missing, the property will be displayed without collation.
|
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
|
- Include the following in the WHERE clause, substituting in the relevant variables for
|
||||||
?infoResource and core:InformationResource:
|
?infoResource and core:InformationResource:
|
||||||
|
|
||||||
OPTIONAL { GRAPH ?g4 { ?subclass rdfs:subClassOf core:InformationResource }
|
OPTIONAL { GRAPH ?g4 { ?subclass rdfs:subClassOf core:InformationResource }
|
||||||
GRAPH ?g5 { ?infoResource a ?subclass }
|
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
|
- Postprocessing removes all but the most specific subclass value from the query result set.
|
||||||
subclass bibo:Book but not bibo:Document, assuming the latter is inferred. If both have been
|
|
||||||
asserted, we will get both.
|
|
||||||
|
|
||||||
----------------------
|
----------------------
|
||||||
Datetimes in the query
|
Datetimes in the query
|
||||||
|
|
|
@ -35,13 +35,19 @@ public abstract class BaseObjectPropertyDataPostProcessor implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
objectPropertyTemplateModel.removeDuplicates(data);
|
processList(data);
|
||||||
|
|
||||||
for (Map<String, String> map : data) {
|
for (Map<String, String> map : data) {
|
||||||
process(map);
|
process(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Postprocessing that applies to the list as a whole - reordering, removing duplicates, etc. */
|
||||||
|
protected void processList(List<Map<String, String>> data) {
|
||||||
|
objectPropertyTemplateModel.removeDuplicates(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Postprocessing that applies to individual list items */
|
||||||
protected abstract void process(Map<String, String> map);
|
protected abstract void process(Map<String, String> map);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void removeDuplicates(List<Map<String, String>> data) {
|
protected void removeDuplicates(List<Map<String, String>> data) {
|
||||||
filterSubclasses(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,
|
* 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
|
* 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(),
|
* the most specific subclass for the object.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
private void filterSubclasses(List<Map<String, String>> statementData) {
|
private void filterSubclasses(List<Map<String, String>> statementData) {
|
||||||
String objectVariableName = getObjectKey();
|
String objectVariableName = getObjectKey();
|
||||||
|
@ -148,44 +146,8 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
log.debug("Data after subclass filtering");
|
log.debug("Data after subclass filtering");
|
||||||
logData(statementData);
|
logData(statementData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List<Map<String, String>> filteredList = new ArrayList<Map<String, String>>();
|
|
||||||
// Set<String> processedObjects = new HashSet<String>();
|
|
||||||
// Iterator<Map<String, String>> iOuter = statementData.iterator();
|
|
||||||
// while (iOuter.hasNext()) {
|
|
||||||
//// for (Map<String, String> map : statementData) {
|
|
||||||
// Map<String, String> outerMap = (Map<String, String>) 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<String> superclassUris = wdf.getVClassDao().getAllSuperClassURIs(outerSubclass);
|
|
||||||
//// List<Map<String, String>> dataForThisObject = new ArrayList<Map<String, String>>();
|
|
||||||
// Iterator<Map<String, String>> iInner = statementData.iterator();
|
|
||||||
// while (iInner.hasNext()) {
|
|
||||||
// Map<String, String> 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<Map<String, String>> {
|
private class SubclassComparator implements Comparator<Map<String, String>> {
|
||||||
|
|
||||||
private VClassDao vclassDao;
|
private VClassDao vclassDao;
|
||||||
|
@ -226,10 +188,8 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, List<ObjectPropertyStatementTemplateModel>> collate(String subjectUri, String propertyUri,
|
private Map<String, List<ObjectPropertyStatementTemplateModel>> collate(String subjectUri, String propertyUri,
|
||||||
|
|
|
@ -196,12 +196,12 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
|
|
||||||
String postprocessorName = config.postprocessor;
|
String postprocessorName = config.postprocessor;
|
||||||
if (postprocessorName == null) {
|
if (postprocessorName == null) {
|
||||||
//return;
|
|
||||||
postprocessorName = DEFAULT_POSTPROCESSOR;
|
postprocessorName = DEFAULT_POSTPROCESSOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> postprocessorClass = Class.forName(postprocessorName);
|
Class<?> postprocessorClass = Class.forName(postprocessorName);
|
||||||
|
// RY If class doesn't exist, use default postprocessor ***
|
||||||
Constructor<?> constructor = postprocessorClass.getConstructor(ObjectPropertyTemplateModel.class, WebappDaoFactory.class);
|
Constructor<?> constructor = postprocessorClass.getConstructor(ObjectPropertyTemplateModel.class, WebappDaoFactory.class);
|
||||||
ObjectPropertyDataPostProcessor postprocessor = (ObjectPropertyDataPostProcessor) constructor.newInstance(this, wdf);
|
ObjectPropertyDataPostProcessor postprocessor = (ObjectPropertyDataPostProcessor) constructor.newInstance(this, wdf);
|
||||||
postprocessor.process(data);
|
postprocessor.process(data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue