NIHVIVO-1510 Provide for display of collated properties as uncollated if the config doesn't specify a collation target.
This commit is contained in:
parent
fc43269ad5
commit
d6906af33b
2 changed files with 41 additions and 11 deletions
|
@ -22,8 +22,17 @@ public class CollatedObjectPropertyTemplateModel extends ObjectPropertyTemplateM
|
|||
private Map<String, List<ObjectPropertyStatementTemplateModel>> collatedStatements;
|
||||
//private List<SubclassList> subclassList;
|
||||
|
||||
CollatedObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) {
|
||||
CollatedObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) throws Exception {
|
||||
super(op, subject, wdf);
|
||||
|
||||
/* RY Temporarily throw an error because collation hasn't been implemented yet. We'll then use an uncollated one instead.
|
||||
* In final version, throw an error if config doesn't contain collation-target element. We'll use an uncollated one instead.
|
||||
*/
|
||||
boolean error = true;
|
||||
if (error) {
|
||||
throw new Exception("No collation target specified for collated object property " + op.getLabel());
|
||||
}
|
||||
|
||||
ObjectPropertyStatementDao opDao = wdf.getObjectPropertyStatementDao();
|
||||
String subjectUri = subject.getURI();
|
||||
String propertyUri = op.getURI();
|
||||
|
|
|
@ -31,7 +31,11 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
super(op);
|
||||
|
||||
// Get the config for this object property
|
||||
try {
|
||||
config = new PropertyListConfig(op);
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getQueryString() {
|
||||
|
@ -43,11 +47,16 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
}
|
||||
|
||||
protected static ObjectPropertyTemplateModel getObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) {
|
||||
// Temporarily comment out, since collation not working. Display as uncollated for now.
|
||||
// return op.getCollateBySubclass() ? new CollatedObjectPropertyTemplateModel(op, subject, wdf)
|
||||
// : new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||
if (op.getCollateBySubclass()) {
|
||||
try {
|
||||
return new CollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||
} catch (Exception e) {
|
||||
return new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||
}
|
||||
} else {
|
||||
return new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||
}
|
||||
}
|
||||
|
||||
private class PropertyListConfig {
|
||||
|
||||
|
@ -61,7 +70,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
private String templateName;
|
||||
private String collationTarget;
|
||||
|
||||
PropertyListConfig(ObjectProperty op) {
|
||||
PropertyListConfig(ObjectProperty op) throws Exception {
|
||||
String filename = DEFAULT_CONFIG_FILE;;
|
||||
|
||||
// Get the config filename from ObjectPropertyDaoJena by looking for the custom property list view annotation.
|
||||
|
@ -88,13 +97,25 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
log.error("Error processing config file " + configFilename + " for object property " + op.getURI(), e);
|
||||
// What should we do here?
|
||||
}
|
||||
|
||||
if (queryString == null) {
|
||||
throw new Exception("Invalid custom view configuration: query string not defined.");
|
||||
}
|
||||
if (templateName == null) {
|
||||
throw new Exception("Invalid custom view configuration: template name not defined.");
|
||||
}
|
||||
}
|
||||
|
||||
private String getConfigValue(Document doc, String nodeName) {
|
||||
NodeList nodes = doc.getElementsByTagName(nodeName);
|
||||
Element element = (Element) nodes.item(0);
|
||||
String value = element.getChildNodes().item(0).getNodeValue();
|
||||
String value = null;
|
||||
if (element != null) {
|
||||
value = element.getChildNodes().item(0).getNodeValue();
|
||||
log.debug("Value of config parameter " + nodeName + " = " + value);
|
||||
} else {
|
||||
log.warn("No value for config parameter " + nodeName);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue