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 Map<String, List<ObjectPropertyStatementTemplateModel>> collatedStatements;
|
||||||
//private List<SubclassList> subclassList;
|
//private List<SubclassList> subclassList;
|
||||||
|
|
||||||
CollatedObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) {
|
CollatedObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) throws Exception {
|
||||||
super(op, subject, wdf);
|
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();
|
ObjectPropertyStatementDao opDao = wdf.getObjectPropertyStatementDao();
|
||||||
String subjectUri = subject.getURI();
|
String subjectUri = subject.getURI();
|
||||||
String propertyUri = op.getURI();
|
String propertyUri = op.getURI();
|
||||||
|
|
|
@ -31,7 +31,11 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
super(op);
|
super(op);
|
||||||
|
|
||||||
// Get the config for this object property
|
// Get the config for this object property
|
||||||
config = new PropertyListConfig(op);
|
try {
|
||||||
|
config = new PropertyListConfig(op);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getQueryString() {
|
protected String getQueryString() {
|
||||||
|
@ -43,10 +47,15 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ObjectPropertyTemplateModel getObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) {
|
protected static ObjectPropertyTemplateModel getObjectPropertyTemplateModel(ObjectProperty op, Individual subject, WebappDaoFactory wdf) {
|
||||||
// Temporarily comment out, since collation not working. Display as uncollated for now.
|
if (op.getCollateBySubclass()) {
|
||||||
// return op.getCollateBySubclass() ? new CollatedObjectPropertyTemplateModel(op, subject, wdf)
|
try {
|
||||||
// : new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
return new CollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||||
return new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
} catch (Exception e) {
|
||||||
|
return new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return new UncollatedObjectPropertyTemplateModel(op, subject, wdf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PropertyListConfig {
|
private class PropertyListConfig {
|
||||||
|
@ -61,7 +70,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
private String templateName;
|
private String templateName;
|
||||||
private String collationTarget;
|
private String collationTarget;
|
||||||
|
|
||||||
PropertyListConfig(ObjectProperty op) {
|
PropertyListConfig(ObjectProperty op) throws Exception {
|
||||||
String filename = DEFAULT_CONFIG_FILE;;
|
String filename = DEFAULT_CONFIG_FILE;;
|
||||||
|
|
||||||
// Get the config filename from ObjectPropertyDaoJena by looking for the custom property list view annotation.
|
// Get the config filename from ObjectPropertyDaoJena by looking for the custom property list view annotation.
|
||||||
|
@ -88,14 +97,26 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
log.error("Error processing config file " + configFilename + " for object property " + op.getURI(), e);
|
log.error("Error processing config file " + configFilename + " for object property " + op.getURI(), e);
|
||||||
// What should we do here?
|
// 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) {
|
private String getConfigValue(Document doc, String nodeName) {
|
||||||
NodeList nodes = doc.getElementsByTagName(nodeName);
|
NodeList nodes = doc.getElementsByTagName(nodeName);
|
||||||
Element element = (Element) nodes.item(0);
|
Element element = (Element) nodes.item(0);
|
||||||
String value = element.getChildNodes().item(0).getNodeValue();
|
String value = null;
|
||||||
log.debug("Value of config parameter " + nodeName + " = " + value);
|
if (element != null) {
|
||||||
return value;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getConfigFilename(String filename) {
|
private String getConfigFilename(String filename) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue