NIHVIVO-1510 Handle rows with null subclasses in collated object property list view
This commit is contained in:
parent
9184b6f70f
commit
46071513f9
2 changed files with 17 additions and 4 deletions
|
@ -50,6 +50,9 @@ public abstract class BaseObjectPropertyDataPostProcessor implements
|
|||
|
||||
/** The SPARQL query results may contain duplicate rows for a single object, if there are multiple solutions
|
||||
* to the entire query. Remove duplicates here by arbitrarily selecting only the first row returned.
|
||||
* Note that in the case of a collated query, the query has filtered out inferred subclasses, but if there
|
||||
* are multiple asserted subclasses, all will be returned. This method will arbitrarily remove all but the
|
||||
* first one returned.
|
||||
* @param List<Map<String, String>> data
|
||||
*/
|
||||
protected void removeDuplicates(List<Map<String, String>> data) {
|
||||
|
@ -59,7 +62,7 @@ public abstract class BaseObjectPropertyDataPostProcessor implements
|
|||
return;
|
||||
}
|
||||
List<String> foundObjects = new ArrayList<String>();
|
||||
log.debug("Processing property: " + objectPropertyTemplateModel.getUri());
|
||||
log.debug("Removing duplicates from property: " + objectPropertyTemplateModel.getUri());
|
||||
Iterator<Map<String, String>> dataIterator = data.iterator();
|
||||
while (dataIterator.hasNext()) {
|
||||
Map<String, String> map = dataIterator.next();
|
||||
|
|
|
@ -67,6 +67,10 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
|||
List<ObjectPropertyStatementTemplateModel> currentList = null;
|
||||
for (Map<String, String> map : statementData) {
|
||||
String subclassUri = map.get("subclass");
|
||||
// Rows with no subclass are put into a subclass map with an empty name.
|
||||
if (subclassUri == null) {
|
||||
subclassUri = "";
|
||||
}
|
||||
if (!subclassUri.equals(currentSubclassUri)) {
|
||||
currentSubclassUri = subclassUri;
|
||||
currentList = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
||||
|
@ -79,9 +83,15 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
|||
}
|
||||
|
||||
private String getSubclassName(String subclassUri, VitroRequest vreq) {
|
||||
String subclassName = null;
|
||||
if (subclassUri.isEmpty()) {
|
||||
subclassName = "";
|
||||
} else {
|
||||
VClassDao vclassDao = vreq.getWebappDaoFactory().getVClassDao();
|
||||
VClass vclass = vclassDao.getVClassByURI(subclassUri);
|
||||
return vclass.getName();
|
||||
subclassName = vclass.getName();
|
||||
}
|
||||
return subclassName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue