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
|
/** 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.
|
* 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
|
* @param List<Map<String, String>> data
|
||||||
*/
|
*/
|
||||||
protected void removeDuplicates(List<Map<String, String>> data) {
|
protected void removeDuplicates(List<Map<String, String>> data) {
|
||||||
|
@ -59,7 +62,7 @@ public abstract class BaseObjectPropertyDataPostProcessor implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<String> foundObjects = new ArrayList<String>();
|
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();
|
Iterator<Map<String, String>> dataIterator = data.iterator();
|
||||||
while (dataIterator.hasNext()) {
|
while (dataIterator.hasNext()) {
|
||||||
Map<String, String> map = dataIterator.next();
|
Map<String, String> map = dataIterator.next();
|
||||||
|
|
|
@ -67,6 +67,10 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
List<ObjectPropertyStatementTemplateModel> currentList = null;
|
List<ObjectPropertyStatementTemplateModel> currentList = null;
|
||||||
for (Map<String, String> map : statementData) {
|
for (Map<String, String> map : statementData) {
|
||||||
String subclassUri = map.get("subclass");
|
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)) {
|
if (!subclassUri.equals(currentSubclassUri)) {
|
||||||
currentSubclassUri = subclassUri;
|
currentSubclassUri = subclassUri;
|
||||||
currentList = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
currentList = new ArrayList<ObjectPropertyStatementTemplateModel>();
|
||||||
|
@ -79,9 +83,15 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSubclassName(String subclassUri, VitroRequest vreq) {
|
private String getSubclassName(String subclassUri, VitroRequest vreq) {
|
||||||
VClassDao vclassDao = vreq.getWebappDaoFactory().getVClassDao();
|
String subclassName = null;
|
||||||
VClass vclass = vclassDao.getVClassByURI(subclassUri);
|
if (subclassUri.isEmpty()) {
|
||||||
return vclass.getName();
|
subclassName = "";
|
||||||
|
} else {
|
||||||
|
VClassDao vclassDao = vreq.getWebappDaoFactory().getVClassDao();
|
||||||
|
VClass vclass = vclassDao.getVClassByURI(subclassUri);
|
||||||
|
subclassName = vclass.getName();
|
||||||
|
}
|
||||||
|
return subclassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue